-
Dinoloop follows this principles. While there are situations, these principles might be discarded.
-
Do not perform null/undefined checks for every method, do it at api exposed level methods. Methods which are closer/next to api must cleanse the data and pass on to inner methods.
-
Test cases should follow
describe(path.to.test.spec.ts)
it([methodname].[returns/throws/[other]_description_seperated_with_dashes])
. -
Comments must be brief and self explanatory particularly on API methods.
-
API methods/properties/classes must be short, notable and easy to remember.
-
Method accepts more than 3 arguments, it is better to prefer objects.
-
There are situations where a method is made public to break down larger code into smaller logical units, to unit test properly. Those methods are not on the interface contract, make a comment at method level when it has to be done.
-
Do not invoke the constructor/new operator inside other classes/methods, it is better design to have static factory method
.create()
on a class which internally invokes new/calls the constructor. Having.create()
static method makes easy to spy on the object creation for unit tests. -
Do not commit package-lock.json, it is a personal choice based on here and here
-
Feel free to suggest and add best practises.
That's it! Happy Coding!