yahya.rafique wrote:
> My intent is figuring out if there is any impact on the evolution of
> design if we put of refactoring until dedicated refactoring sessions
> that are spaced apart in time as opposed to immediately addressing needs
> as "code smells" are detected. Intuitively the technical debt is larger
> but I was wondering if there are any other adverse effects on design
I don't think one can answer this question meaningfully in general, as
the tradeoff depends on so many variables: the strength of the design,
the programming language, the skill of the programmers, the technology
domain of the project, and 1000 other things.
Some say that if you ever want to have "a refactoring session" then
you're not refactoring enough. For many teams, I find that to be a
useful rule of thumb, but I like to distinguish two kinds of
refactoring: cleaning the kitchen and cleaning the garage.
Cleaning the kitchen happens when you refactor as you go. This is like
cleaning a pot just after you use it, because you have 30 seconds before
you have to turn the chicken in the pan on the stove. Most programmers
need to clean the kitchen more, although some programmers (including me
at times) clean the kitchen too much. In programming, we don't have
chicken burning in the pan to remind us to stop polishing the pot. For
that, we need to rely on our own judgment and pair partners. When I
clean the kitchen (in refactoring), I expect my pair partner to keep
asking me "Why are you doing this right now?" If I can't answer her,
then I know I'm just polishing the pot, and have to move on to the next
part of the task.
Cleaning the garage happens when progress grinds to a halt because some
part of the system has been left to rot too long. This is like cleaning
the garage because your car doesn't fit in it any more. You take a
weekend and move all the boxes, fit in your car, figure out what to
throw away and what to keep, then reorganize what you decided to keep. I
usually don't like to clean the garage, because it's a big job, so I
tend not to do it. On the other hand, if I don't see patterns in the
things in the garage, then I don't know how to organize it all. A mess
of things is the same mess as a mess of boxes, each with one thing in
it. Just because things are in boxes, that doesn't mean we've organized
them.
I find that I follow a simple pattern:
1. Assume that I don't clean the kitchen enough, so clean it more.
2. Someone notices that I'm cleaning the kitchen too much, so I clean it
less.
3. By not cleaning the kitchen enough, I end up with a miniature
garage-like mess, which takes hours or a day or two to clean up.
4. Not liking the experience of cleaning a small garage, I pay more
attention to cleaning the kitchen. Goto 1.
I not only find this pattern natural, but I suspect one can't really
avoid it. Over time, each team settles into a rhythm where they clean
the kitchen just enough and clean a garage every so often.
--
J. B. Rainsberger :: http://www.jbrains.ca ::
http://www.thecodewhisperer.com