I _Really_ Don't Know

A low-frequency blog by Rob Styles

Tidy or Organised

Rachel Davies (she's a top-notch agile coach if you're looking for one) discusses the term refactoring and suggests it may be unhelpful.

She suggests calling it Tidying Up instead as then it's clear what we're doing.

I agree with Rachel whole-heartedly that the term is somewhat grandiose when talking about the work with non-technical project members, but I don't think it's just tidying up - it's organising.

The disctinction I make comes from conversation with colleagues about home life, rather than work life. Those moments at home when you tidy up and that means putting several ramshackle piles of paper into one neatly stacked pile, putting all the books back on the book-shelf and doing some dusting and hoovering. Organising, on the other hand, is a much more cerebral activity - maybe sorting that pile of papers into several piles; one for the car insurance, MOT certificate and service history and others for house-stuff, work-stuff etc. You might even decide to buy some colour-coded folders for them all!

While a lot of what we need to do with code is tidying up - last week I re-sorted the entries in a (rather large) configuration file so there was some meaning to the order; I also spent some time re-formatting large sections of code to keep the indentation and whitespace sensible, as well as changing the offending IDE settings to keep things straight in future. This is all tidying up; it doesn't change the meaning conveyed by the code.

Re-factoring (rob waves an arm ostentatiously as he rolls the term across his palette) on the other hand is about putting more meaning into the code. It's about making the code more organised, rather than just tidier.

The Alpha list of refactorings, maintained by Martin Fowler, lists a great number of different refactoring patterns. There are things like Add Parameter, which allows a method to say that it needs more information from its caller, Collapse Hierarchy, which combines two not very different classes into one, and so on. These are about making the code describe the problem more clearly by organising the code into meaningful piles.

In my experience this is more than tidying up.


Rachel Davies

Hi Rob, I completely agree. Refactoring is more like reorganising. I homed in on the phrase "tidying up" because I was trying to get away from the pretentiousness of the word "refactoring" which is so meaningless for business folk. However, the activity that I was thinking about was much more than just putting things away rather finding or creating the right place for the access required, Merry Xmas, Rachel x