Coding Guidelines
A general guideline is to follow the clean code principles for any new code we write or existing code we modify. Also, emphasis is laid on testing. Having a corresponding unit test for every class will make sure the code we have written is actually exercised once before being deployed. This way, we can avoid nasty bugs and make maintenance easier.
Some of the coding guidelines include:
- Using meaningful names for functions and variables
- Writing small functions (3-4 lines would be ideal. Max of 10 lines) and having only one purpose in one function
- Every function, and every block within a function, should have one entry and one return statement
- Avoid writing duplicate code
- Follow the 'girl scout'/‘boy scout’ rule of leaving the code cleaner than one finds it
- For indentation, follow the BSD/Allman style
- Use 4 spaces for indentation in place of hard tabs (does not apply to golang as tabs are recommended there)