For the past three months, I have been sharing code quality tips within my place of work in the hopes to help improve code deliverables. I am now moving the location of the repository to my blog in hopes that more than those at work may be able to increase their code quality.
This week’s tip is around practice. Often the demands made upon developers to produce a feature yesterday have developers compromise the quality of their code. Principles such as unit tests for newly written code, descriptive and meaningful names for functions and variables, etc.. all go away with the demand to get the code written as fast as possible. What doesn’t get compromised are principles and patterns ingrained as habits.
Katas and code challenges are great tools to help develop code principles into your muscle memory. If you find that you are sacrificing the unit test coverage of your code due to the demands of getting that feature written as quickly as possible, take some time each evening and one work on a Kata and practice writing unit tests first for your solution. Doing this until it becomes part second nature will yield improvement with your code by making it a habit where you naturally start writing unit tests before you write your feature.
Take a code quality principle that you want to have part of your craft and create a plan to work on it each day until it starts becoming habitual. I suggest having the project for at least two to four weeks, by focusing on one principle for this period will help ingrain that principle that your code will follow it naturally.