dagfinn | 11 October, 2008 14:41
Refactoring is by definition a design actitivity, since the definition of refactoring is "improving the design of existing code". But is this generally and fully recognized? After attending my friendly local agile conference (Smidig2008—sorry, it's in Norwegian), I'm getting more of a feel for how different people think about it. And I'm wondering whether the use of metaphors such as "cleaning" makes refactoring seem too much like unskilled labor. After all, physical cleaning jobs are seen that way.
The analogy between cleaning and refactoring is useful for making the non-developers understand that refactoring is absolutely necessary. But beyond this pragmatic similarity, are the two really similar in deep and meaningful ways? I don't think so. Refactoring is not unskilled labor. It's a task that both requires and builds design skill and experience. While anyone can see that a floor is dirty, identifying code smells is non-obvious, tricky and demanding. This is true even of the simplest code smell, duplicated code. Although spotting code duplication is sometimes easy, at other times, the duplication is too subtle to be easily identifable. When you clean a floor, the goal is well-defined and easy to visualize. When refactoring, you may know what you're aiming for at each small step, but just a few moves further ahead you may end up with a structure you hadn't imagined.
Paul Geraghty | 12/10/2008, 19:30
Servicing your own car might provide a better analogy.
It can be quite simple to do, but it can go horribly wrong - you forget to tighten the wheelnuts ...
You can completely screw your engine with just a small oversight. Ever cleaned a carburettor, put it back together and spotted one tiny screw left sitting in the dish?
But, after the service and your car is running well the sense of achievement and well being is quite something. Every time you delve under the bonnet you learn something else, you investigate another component you didn't need to look at, but you started disassembling it anyway. What exactly does that box do?
You seek out others willing to share their experience. Suddenly you are aware of cheap and reusable components. Good Lord, this car can run on corn oil.
The process of servicing your own car can be time consuming but very rewarding, and can save you a lot of money.
Sometimes I drive with the window down just to hear the noises coming out of the engine and from the drives and suspension.
"Hang on, that's a new squeak it wasn't there last week"
Split timing belt anyone?
| « | January 2009 | » | ||||
|---|---|---|---|---|---|---|
| Su | Mo | Tu | We | Th | Fr | Sa |
| 1 | 2 | 3 | ||||
| 4 | 5 | 6 | 7 | 8 | 9 | 10 |
| 11 | 12 | 13 | 14 | 15 | 16 | 17 |
| 18 | 19 | 20 | 21 | 22 | 23 | 24 |
| 25 | 26 | 27 | 28 | 29 | 30 | 31 |
Re: Refactoring is design
Karianne Berg | 12/10/2008, 04:10
You make an interesting point about the "cleaning" metaphore for refactoring and restructuring code. After all, cleaning is generally seen as something that is boring but necessary. Refactoring can, as you mention, be both satisfying and challenging.
It was nice to meet you at Smidig 2008!