Coding Standards and Style Guides
Created: September 25, 2020
In yesterday's email, I said "Code Review backed by Code Standards and Style Guides" was the second most important thing a SuiteScript team needs for long-term success, so let's discuss it.
Code review is a crucial part of a cohesive development team. When used effectively, there is no better method for creating consistent, readable, maintainable code bases.
In order to be used effectively, however, everyone on the team has to know what constitutes "good code" for that team. The best way I've found to do that is to establish, document, and onboard team members with code standards and style guides.
There are a ton of amazing resources which you can find on these topics, and many teams/companies actually publish their standards. Here are a few of my favorites:
- Douglas Crockford's Code Conventions for JavaScript. If you're unfamiliar with Douglas Crockford, I cannot recommend his work highly enough. (No affiliation, just a huge fan)
- Google's JavaScript Style Guide
- Wordpress' JavaScript Style Guide
- airbnb's JavaScript Style Guide
About 17.7 million other pages
Establishing standards and style guides will give you firm ground on which your team can base their code reviews. Furthermore, once they're established, these standards can be leveraged in automations to make the development process even more efficient. Most IDEs have code formatters and validators which can be configured based on your standards, and there are plenty of JavaScript linting tools that will automatically checking code against standards and potentially fix any issues before they reach the review stage - let alone the testing stage or, worse, the Production stage.
If you've already implemented the_most_important component, source control, and you're using an effective branching scheme like we discussed in that email series, then your merge/pull request stage is the ideal place for code review to take place.
What has your experience been with code review and standards?