January 10, 2021Improving code quality
Improving code quality
As a code base matures, contributors will come and go. The styles, opinions and patterns will evolve. As will your thinking about the most well suited and elegant solution.
🍎 Low hanging fruit
The items below I see as no-brainer areas of quick improvement. Once configured correctly they provide continuous feedback throughout the Software Development Lifecycle, SDLC.
Prettier is “An opinionated code formatter” which supports many languages. It easily integrates with most editors with limited configuration options. It allows us to enforce rules around our code style. When configured to run on save it becomes a tool to increase productivity and code consistency.
If you don’t have any tests, you should. If you do have tests, congrats!
Now are you measuring how much code is tested? Can you see where the “gaps” in your coverage are? Tools like CodeCov can not only help us answer these questions, but it can also be configure directly into GH and our CI/CD pipelines. Now with each PR submitted we can monitor how these metrics are changing.
Writing Boilerplate sucks, there is no denying that… So why not “generate” it more dynamically? Well this is why I built a generic NPM / CLI tool to speed this process up. It allows us to create any number of “templates” from the CLI with minimal efforts. Such templates can be configured as you see fit, and updated as your technology and preferred patterns change. Read more.
⚙️ Process Changes
Depending on the size of the team(s) and varying experience level of the contributors in can be difficult to know when there is a better way. But modern day code is written by a “team”. The best teams are those that challenge themselves to improve day in and day out.
Keep them small and focused! I’ve seen WAY TOO MANY PR’s go sideways by growing too large. We can avoid this through better preparation and planning. Keeping these changes smaller favors speed, iteration and improved feedback loops from all participants.
Now that you’ve made some changes how we keep the momentum. Tools like Husky can be used to trigger our linters and test suite as we go about our day coding. Lastly, everything noted above can be tightly integrated into our CI/CD pipelines.
More often than not, we’ve already moved onto the next feature before having the opportunity to cleanup. Depending on the project, or Agency vs. Product team we often times struggle with doing it “right” or “right now” and there is no silver bullet.
This is by no means an “exhaustive list” but a great starting point for teams looking to improve Code Quality.
The code we write and ship to customers matters and we should strive to produce the highest quality experience at all times.