Refactoring Doesn’t Mean Rewrite

[article]
Summary:

Peter Schuh writes that it is not a good thing that the use of the term refactoring has grown so common, which makes him cringe every time he hears a business person say the word. Refactoring is meant to be one skill of many that is second-nature to a journeyman programmer.

“You keep using that word. I do not think it means what you think it means.”

-Inigo Montoya from The Princess Bride

It is not a good thing that use of the term refactoring has grown so common. I cringe every time I hear a business person say the word.

Refactoring is meant to be one skill of many that is second-nature to a journeyman programmer. While doing other work, the programmer chooses not to ignore rough patches or unnecessary complication within method-level bits of code. Instead, the programmer pauses to sweep up and simplify, leaving the code cleaner than when he started. Interfaces are not altered. Outward behavior does not change. The benefit is forward-looking - since cleaner, simpler code that does the same thing is easier to maintain and build upon. As a craft, refactoring is meant to go unnoticed (although not unappreciated) by the business and the end user.

A rewrite is just what it sounds like. When the system can’t scale to satisfy peak loads, or the user interface is clunky, or interfaces to external systems are bug-ridden and obtuse, we need to consider a rewrite of portions or all of the code. We need to get permission from the business. Sometimes, we need the user to buy into the investment of migrating from one system or UI paradigm to another. We need funding. Every time I hear a business person (or, so much worse, a developer) say we need to refactor some part of the system to fix an issue or inefficiency, another hair follicle leaps from the top of my head and embeds itself in the side of my ear.

Why do I care? It’s just semantics. Well … it’s only semantics until someone gets hurt. Rewriting code is a risky and sometimes painful endeavor. It doesn’t always end well. If we execute a rewrite but call it a refactor and the whole thing goes pear-shaped, no business person is going to stop and think about semantics. They’re just going to cringe the next time they hear the word refactor. And when a journeyman programmer comes along and someone lets it slip that the programmer has been refactoring code without telling anyone - it’s going to cause all sorts of unnecessary confusion and consternation.

The business will believe programmers are taking prioritization decisions into their own hands. They’ll think that risks are being taken by a team of “cowboys” who cannot follow disciplined programming practices. And they’ll be justified in thinking that, because we could not keep our terms straight.

Author:Peter Schuh

About the author

CMCrossroads is a TechWell community.

Through conferences, training, consulting, and online resources, TechWell helps you develop and deliver great software every day.