
Coding Guidelines
Use
modulepattern whenever possible. But do you know the reason why? Let me explain it to you.
-- Modules are executed within their own scope and not in global scope.-- Code reusability.
-- Encapsulation
-- Load on demand
-- Easier testing
Avoid using
namespaceif modules is a possibility. Why? As you might end up importing the whole standard namespace into your program which may not be required.Organize single class into a single file.
Import only required module and retain naming convention.
Use
default exportfor 1 major class andnamed exportfor less frequent or related classesRefrain from using
underscore (_)anywhere, not in field name or get/set. Why? As such a naming convention indicates a name is meant for internal use.TSLintdoesn't respect the underscore pattern naming convention.Do not create
asyncif only last return statement hasawait. Do not omitasync/awaitwhen catching exceptions.
Will share another article on async tips soon! Till then happy learning.
![]() | ![]() | ![]() | ![]() |
| Like | Comment | Save | Share |




/api/attachments/att/4/linkedin-null-nan-1200-628.png/linkedin-null-nan-1200-628.100.jpg)
/api/attachments/att/249/webP.gif/webP.100.jpg)