Coding Guidelines
Use
module
pattern 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
namespace
if 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 export
for 1 major class andnamed export
for 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.TSLint
doesn't respect the underscore pattern naming convention.Do not create
async
if only last return statement hasawait
. Do not omitasync/await
when catching exceptions.
Will share another article on async tips
soon! Till then happy learning.
Like | Comment | Save | Share |