Refactoring Trumps Yagni

This is my take on the less-aggressively-phrased argument in OaooBalancesYagni or SimpleDesignTrumpsYagni (Yagni = YouArentGonnaNeedIt).

-- AlexChaffee

From http://www.purpletech.com/xp/bootstrap.txt :

8/6/2002: The past three sessions, my pairs and I have been refactoring the Library and Item classes to be more object-oriented. This follows one of my big revelations, which I'm sure every Extreme Programmer must learn, and must constantly relearn:

Simple Design trumps YAGNI

meaning that writing clean, clear, object-oriented code is very important, and that if you have a choice between (a) leaving your code smelly and implementing a new feature, or (b) refactoring and letting the feature wait a little while, you should refactor.

Unfortunately, if you let your refactoring duties slip, you will end up needing to perform a lot of refactorings with fairly large scope. See NoseJobRefactoring for one technique for accomplishing this.

The bigger lesson, of course, is

Don't Check Your Brain At The Door

and that we should have been doing these OO refactorings all along. Maybe even as soon as we got the code to work using "String title", we should have taken half a step back, applied the "Replace Value With Object" refactoring, and been satisfied that we had made the code more aesthetically pleasing and therefore better --

-- even though it wasn't to satisfy a user story.

In other words, refactoring is a technical decision, not a business decision, and the customer has no right to tell us not to do it (even if he does so implicitly, or if it's just our own puritanical super-egos saying "Work! Be more productive! Don't refactor, write a new story!").


My take on YouArentGonnaNeedIt has always been that it applies to additions to functionality (including under-the-hood ones). Under this understanding, one would never even think to skip refactoring (or other SimpleDesign activities).

I know Yagni is one of those hammers that makes everything look like a nail, and once the scales fall from your eyes it's tempting to find lots of things you don't really need to be doing now. Still, I don't think it's intended to apply to anything but added complexity (which is clear if you read a lot of the arguments for Yagni, with their references to carrying costs and the like).

Perhaps it's time to rename it: YouArentGonnaNeedThatFeature?, or YouArentGonnaNeedThatInfrastructure?, or YouArentGonnaNeedThatComplexity?, or YouArentGonnaNeedThatComplication?, or maybe YouArentGonnaNeedThatYet?....

--GeorgePaci


CategoryRefactoring


EditText of this page (last edited March 18, 2003) or FindPage with title or text search