RSS

Refactoring in Real Life

pipes-before1

While upgrading my kitchen last weekend I encountered a great opportunity to simplify the plumbing. The experience resonated with how I think about software projects.

pipes-after1

I had to make room for an integrated dishwasher beside the sink. It needed to be completely flush with the wall. The pipes sprawled half the width of the worktop, mostly completely redundant. Previous quick fixes and badly thought out additions left it harder to understand, and more time consuming to change. I managed to remove meters of pipe and dozens of joins, without changing external behaviour. Others before me skipped the oppurtunity, costing me extra time to make my change.

pipes-pile1

The cardinal rule of software evolution is to improve internal quality when making changes. The principle being: change is inevitable, and messy code is harder to change, so reduce the cost of change by a constant attention to code quality.

The messy plumbing only cost me a few hours work. I won’t look at it again for 10 years. With software your ability to change is your only lifeline. Plan for change. Your good decisions today, may be bad decisions tomorrow, make them quickly and change when you know better.