13 reasons why coding standards & best practices are necessary

Manu mathew
Techdev
Published in
4 min readJul 31, 2021

--

13 reasons why coding standards and best practices are necessary.

Someday when you joined as a junior and there would have been that one senior or manager who was adamant about following coding standards. You might have felt it so frustrating when your code review or Pull request kept coming back despite it working perfectly. Coding standards might be a nightmare for many of us when we start working on real-time projects. Well, here are some practical reasons why we really need coding standards. I will be covering various coding standards and best practices in coming blogs.

While you were working on a college or personal project, probably you might have been the only contributor and you know the project from scratch but when it comes to projects where multiple people are working currently or going to work in the future, things will get complicated and extremely messy unless we put some checks.

  • No real-time project would be as small as few lines of code or modules. At some point as the code base grows large and things will become a humongous mess. We might find it difficult to understand our own code. Using proper naming conventions and comments would be helpful in such situations.
    * In large modules, it is quite confusing to understand what value is held by which variable down the line. Meaningful names for variables will help the developer avoid this confusion.
    * The code you are working on right now might have been written by somebody a long time ago or some developer might have to work on it a long time after you wrote it. If there are some project-level coding standards and best practices and if it is documented, it will be easy for any person to refer and understand the code and work on it.
    * Code refactoring — There could be scenarios where you will have to do some code refactoring which could be as small as changing a value used in the computation. However, if the value is used a large number of times, then even this small change will be hectic unless the best practices are followed. For example: Defining values as constants or keeping them in configuration or settings file.
    * Working with multiple environments — Most real-time projects would follow some workflow involving multiple environments such as dev, testing / QA / Stage, Preproduction, Production, etc. There will be many parameters that will be different in each environment which needs to be handled environment-wise based on preset rules.
    * Code scalability and maintenance- We never know the future possibilities or requirement changes that could occur in the future. It is always good to follow some good coding practices (like the SOLID principle) to keep the code as scalable as possible.
    * Readability — Proper indentation and spacing make a code appear clean and easy to read. It helps people (including you and especially you) who would have to read the code someday later to understand it or work on it.
    * Avoiding mistakes — Silly mistakes that get injected into code might require a significant amount of time and work for correction but might have been avoidable had the code been kept clean and standardized. For example mistakes like missing indentation or misplaced indentation could be avoided if proper indentation is followed.
    * Security issues — Improper coding vulnerabilities such as SQL injection can be easily avoided by following best practices.
    * Code optimization — When code is rewritten over and over again, even worse when multiple people rework it, the code could become quite messy and poor performing. This could be avoided if everyone who touches a piece of code ensures to follow the defined guidelines. For example, Avoiding DB fetches inside a loop.
    * Redundant code — This again could be the result of reworks. A lot of redundant code can be avoided by following principles of modularisation, abstraction, or best practices.
    * Reusability — Almost the same as the above point. DRY principle ensures that no two pieces of code that do the same must exist.
    * Integration — Sometimes applications need to be integrated with other applications or another application may need to be integrated into ours. Following standard design patterns, REST principles, etc can ensure that this integration or merging is a smooth process and bug-free.

Let me know in comments what are some of the reasons you can think of.

--

--

Manu mathew
Techdev

Software engineer in Silicon valley of India - Bangalore/Bengaluru