Broken windows - the deterioration of software

It's easy to overlook technical debt in your code base and remind yourself to come back to it later. However, experience tells us that this is a bad idea.

An abandoned building can remain in pretty good condition for some time. But once someone comes along and breaks that first window, It doesn’t take long before all the other windows are broken, and the building slowly becomes a ruin.

Leaving dead code, poorly designed or maintained code, duplicate code, etc becomes a broken window in the codebase. When another developer sees that broken window, they don’t feel so bad about breaking other windows - leaving poorly written code in their wake and making the codebase worse and worse until it’s beyond repair.

With the help of a comprehensive test suite, refactoring code before adding any new features or making any other changes is an effective tool in preventing the project from becoming unmaintainable.

When adding new features, following Test-Driven Development (or TDD) is our prefered method. TDD consists of 3 basis steps, know as Red-Green-Refactor.

  1. Red: Write a failing test, just one.
  2. Green: Write your application code to make that test pass
  3. Refactor: Before moving on, refactor the application code to improve its structure.

By fixing broken windows slowly but surely, it becomes much easier to keep the codebase clean.