Refactor Low Hanging Fruit
Of course, with any approach, you will always encounter situations where you have to rewrite major portions of the code, or, worse, change the entire architecture. This is likely to happen due to requirement changes, or performance issues, but can happen because your initial visualization was faulty. In real life, what typically happens is, after the twister, your house lands on top of the previous lead architect, and you peer tremulously out the door at a twisted landscape of big balls of crufty mud, written by short programmers, their growth stunted by long working hours and junk food, under the spell of some lesser process than XP.This leaves you wondering where to start. Then MichaelFeathers, wearing a Wikid Witch of the North costume, appears with a copy of The Joy of LegacyCode, and smacks you across the forehead with it.
DOROTHY
But -- after I add tests to all this legacy code, how to I fix it? Do I
split it down the middle? Do I look for the big common patterns ---
MIKE
Just refactor the low hanging fruit.
DOROTHY
But that sounds too easy! Shouldn't I make a plan too...
But MIKE floats away inside a SOAP bubble, leaving you all alone. With the short programmers crowding around you.
DOROTHY
My..! People turnover so quickly here!
... Refactor the low hanging fruit? Refactor the
the low hanging fruit?
DBA
Refactor the low hanging fruit.
TOOLS GUY
Refactor the low hanging fruit!
GUI GUY
Refactor the low hanging fruit.
MATH GUY
Refactor the low hanging fruit.
ALL
Refactor the low hanging fruit.
Refactor the low hanging fruit.
Refactor, factor, factor, factor,
Refactor the low hanging fruit.
Refactor the low-hanging
refactor the...
So, by finding the simplest possible fixes to the lowest level code within that ball of mud, and by isolating the effects of your changes with characterization tests, you can begin to tease apart its design.… And … you … are …
Testing your way to dee-velopment
Developing tests for the cause
You'l find it a whiz, so give it a squiz
Each test just gives one little pause
The tests you test are bestests tests
The bests are tests to test the best
Because ... because
because, because, because,
Because of the wonderful code they does.
You're testing your way to dee-velopment
The wonderful tests for the cause!