Published July 22, 2020
by Doug Klugh

Enhancing Software Quality

Make it a habit to continuously improve the design of your software through refactoring and optimization.  Refactor your code to improve its Structural Quality and optimize your code to improve resource utilization.  If applied correctly, these techniques will enhance the quality of your software without affecting its behavior.  Remember to refactor your code before optimizing to make your software more adaptable to performance tuning.

Preserving Behavior

During software development, we should focus on changing either the structure, functionality, or resource usage of our software — and only one at a time.  Changing the structure or resource usage without impacting existing functionality can be challenging.  Preserving existing behavior involves more than just leaving the code alone.  We need to know how much of the behavior is at risk and have a method of knowing that the behavior isn’t changing.

Dodging Defects

Many of us avoid attempts to improve design because we are afraid of breaking existing functionality or introducing defects.  But we can mitigate this fear by making sure we have a comprehensive set of mature unit tests that serve as a Safety Net.  Running these tests after every code change will ensure that we catch errors as soon as they are introduced into the code.  Then fixing those errors, or simply backing them out, becomes a trivial task.  Press CTL-Z a few times and you are right back to where you started before the error was introduced.  And if your tests really are Unit Tests — meaning they are verifying small, isolated units of functionality — they should run fast enough to allow you to run the entire suite after changing each line of code.  This is how you alleviate the fear of improving your design and avoid introducing defects.