-
Continue reading →: Check the values of all data from external sources
When getting data from a file Verify that if it has valid extensions/file type Verify that it does not exceeds certain file size When getting data from a a user, the network, or some other external interface Check to be sure that the data falls within the allowable range. Make…
-
Be symmetric while writing methods
Published by
on
Continue reading →: Be symmetric while writing methodsWhen working with class or module sometimes you would need equal and opposite operations. The methods should be symmetric. Please make sure they are not added causally that would add non symmetric verbs. Not symmetric turnOn()/disable() openConnection()/shutConnection() increaseVolume()/turndownVolume() push/remove If you are adding symmetric methods, then make sure they feel…
-
Continue reading →: Functions in JavaScript are objects
Functions in JavaScript are objects. How to know in the browser? Navigate to the console of the browser near you and type this simple function Person shown below and hit enter. Next, type Person followed by dot (.) see the methods on Person function. Pretty simple. Thus the function is…
-
Continue reading →: Avoid deeply nested ternary operator
?: is a ternary operator introduced to write elegant if-else clause. It is a concise way of writing simple conditionals. However, those should be easily understandable by any human. It should not be used to write deeply nested complex conditionals that hamper the readability. When to use? When you have…
-
Continue reading →: Primitive Obsession – The code smell
Programming languages divide their types mainly into two categories. Primitive types (A built-in types like string, boolean, int, decimal…) Objects (class/function): User-defined types using class-based/prototype-based objects. A primitive data type is a data type for which the programming language provides built-in support. Example: number, string, boolean, date and so on.…
-
Continue reading →: Some design guidelines developers need to know
4 Rules of Simple Design Domain-Driven Design SOLID Patterns Law of Demeter Tell, Don’t Ask POLA/S Design by Contract Feature Envy Cohesion Coupling Balanced Abstraction Principle
-
Continue reading →: Test case structure
A commonly applied structure for test cases has Setup: Arrange the state of the unit under test in order to run the test. Execution: Act on the unit under test so that it performs the expected behavior and receive output if needed. Validation: Assert/Verify the outcome of execution. Cleanup: Restore…
-
Continue reading →: Test-driven development benefits
Design first: You understand requirement first via analysis, create use cases for it. Thus, the focus is on the requirement before writing the code. Good enough code for now: You write sufficient code against use cases that fulfills the user requirements. You don’t write extra lines of unnecessary code. Avoid…
