Wednesday, May 19, 2004

Under-design vs. Over-design

I've been throwing a question in my head for a while and I thought I'd post about it. The question is simple: What's better under-design or over-design? Sure, the extreme cases of both are bad (awful would be a better word) and painful. But, what about the less extreme cases? I would imagine everyone would agree that good design is in the middle (not too much, not too little). Good design is easy to work with and easy to make changes to. But, a shift either way is under or over design. Now, I don't live in a perfect world and most designs I've seen tend to go to one side or another. I've been asking anyone within earshot what they think and the answers have been very enlightening. My first gut instinct would be to err on the side of over-design, but I think this from coming from the non-XP world. But, now, since I've been doing XP for a little while. I think I would rather land on the side of under design. Why you ask? A lot of people think XP is devoid of design (which is think is absolutely wrong). It's just in XP, we design what we need today and refactor unmercilessly as we go along. The "refactor unmercilessly" is the key phrase because without it you get a severe case of under design and your code becomes painful to maintain. Back in the old days (pre-XP), I was on teams that would design for months before we wrote any code. What we usually got was way over-designed code that had to be changed anyway because of forces of the real world (always making our elegant code messy! How dare it!). When I first started to play with XP, I knew it was a good way to go but was scared about "only design for today" adage. But, what I found is the systems are more adaptable to change. The only time we have problems is when we get into time crunches and forget to "refactor unmercilessly". I think I go back to my saying, "Design for today, but your keep your eye on the future". Lots of times you can add "hooks" to your code that allo extensibility for future enhancements without sacrificing succintness nor adding complexity or code. Think before you code! XP is not about blind coding without thought (which I have heard arguments as such). So, what's everyone else's opinion? I don't know if there is a right answer because each has it's plues and minuses. But, from my experience, a little bit of under design is better than over design. Your mileage might vary of course.

No comments: