General principles

Focus on writing well

Any time spent writing the code is spent only once. Any time spent reading the code is spent every single time it is read.

Names must match contents

Functions must do what their names say—no more and no less

Low level functions must do things and it should be minimal. HighLevel functions must call low level functions and avoid doing things themselves. Define Low level and hight level.

Naming is highly depends on context.

Variables must contain what their names say—no more and no less

Anything which is public in a module must have header documentation

Importantly, this does not preclude anything which is not public from having header documentation.

Define the behaviour first and then write the code

Preferably with tests.

null vs undefined

In languages with support for both null and undefined, undefined means we have not set anything for this variable yet, such as when we are waiting for a response from a remote server, while null means that something has been explicitly set to nothing, such as the response from the server said that there is no list of items to display (not an empty list, but there is no list at all).

Last updated