What coding standards should you adopt for your company? Ask 10 developers, and you’ll get 11 answers. Rather than prescribe a solution for your company, we suggest reviewing the following options first. But a word of caution: It’s easy to go overboard with coding standards. A small number of rules or principles will go a long way.
The principles approach to coding standards
Rather than discussing specific technologies and providing samples, the principles approach goes a different way. For instance, think about the Manifesto for Agile Software Development. You can see that as a principles approach when it suggests: “Business people and developers must work together daily throughout the project.”
The main problem of this approach? Developing robust first principles takes some serious thinking! It’s not going to be an overnight process. The benefit is that your company will have broad ideas that can be applied to a variety of circumstances.
Issues to consider when creating coding standards:
- Emphasize decision making values. Principles help guide how a developer approaches code. For example, the agile emphasis on close collaboration with the business helps you plan your daily coding work.
- Prioritize the long term. A principles-based coding standard should be able to stand for two or three years without any changes.
The procedures approach: Coding standards with all the details
In other situations, it makes sense to push for detailed procedures. If your company has armies of developers and you are struggling to stay consistent, procedures may be a better approach.
- Choose one focus language. Your company may use JavaScript, C#, and PHP. Covering all of these in your coding standards may not be practical. For example, take a look at the Coding Standards for JavaScript.
- Balance theory and practice. For procedures to be beneficial, state a broad principle (for example, write comments in clear English with minimal slang) and provide examples of good code.
- Set a length limit. A 200-page coding standard document, even if valuable, won’t encourage developers to open the document.
Final coding standards tips
If you use the procedures approach to coding standards, appoint someone to own and maintain the standards. Otherwise, you may end up with an out of date document that provides little value.
Now based on those options, make some choices about what makes sense for your company. Balance your personal preferences with what your customers value. For instance, national defense customers will place a high value on security and internal control. If that’s what your customers want, then start building those points into your product.