Refactoring Factor Esther Schindler wonders about the reasons
behind a study that shows only 22% of developers consider refactoring
important. Before writing the article She asked some questions on the agile-testing
list and her article includes some of the points in the responses.
I want to focus a bit on her primary conclusion, that programmers can't
get resources or buy-in to do refactoring.
Because the programmer's managers won't allow it
Somewhere I think I have the email directive that a project manager sent
out at one job I was on that said, to paraphrase, that anything beyond
the specific changes requested was a "refactoring effort" and therefore
out of scope.
Now there is a simple explanation and a not-so-simple one for this.
The simple one is the spread of what Martin Fowler wrote about in
must confess I probably contributed
to it in the above mentioned situation, and I'm still paying penance
Now the complex explanation. Project management can be seen as
the task of maximizing the completed features in the available
time within the budget of money and people. In too many
situations, the estimates of time required are abbreviated. This
happens stereotypically by management, as Phillip Su writes in Broken
Windows Theory , but it also happens because many programmers lack
sophistication estimating. The programmers typically consider the time
only to write the code and get it to compile and running, leaving out
the other tasks that get the code from "done" to "shippable". One reason
I've come to favor agile development styles is that they reduce the time
and disconnect between those two states. Anyway, the result is that the
schedules are wrong, the projects get behind, and the solution adopted by
teams is typically to cut everything else except the promised features.
Short term gain, for long term loss, because the technical debt builds up.
Now management has a hard time seeing the effects of technical debt.
They see that as a project goes along and a product grows, adding new
features and fixing existing code that doesn't work as desired takes more
time and becomes increasingly more likely to introduce new problems.
But by the time these manifest as the level of most projects, the
technical debt has built up to dangerous levels. The typical example I
give is what if a 5-star restaurant were to hire a lot of chefs and not
enough dishwashers, and decreed that the chefs must ONLY cook, never
clean up. Initially they'd be able to feed a lot of people, but as
the dirty utensils and pots and pans build up, the chefs increasingly
have to hunt for clean ones and a place to work. Gunk builds up on
the grill. After a certain point, if we followed the typical IT shop
solution, the restaurant would throw out all the dirty stuff, replaces
the appliances that can't be salvaged, and if necessary hire new chefs.
Of course great restaurants don't work like that. They and their chefs are
cleaning as they go, so that pan or knife that was used for the happy hour
buffet prep gets returned to use for the dinner entree and then dessert.
Refactoring is cleaning the kitchen while you cook. It's not sexy, it
doesn't make the souffle fluffier or the piecrust flakier, but it's a
given that if it's not done, there won't be any souffle or pie at all.