Wow, what a productive week!

No, I'm not kidding. I'm on fire, kids. Just having a good week, cranking out lots of good, working code. I've been kickin' ass and chewin' gum, and I'm almost out of gum. You know how it is: sometimes you're on and sometimes you're not. This week I was on.
Something I'm feeling good about: I have a large degree of autonomy on my latest project. I gathered a pile of requirements and went to town. Just for kicks, I decided to try a development approach I've read about but never got to try in a production environment: refactoring to patterns.

For those of you who are old hands at this, accept my apologies, stop reading this, and go watch Arrested Development instead. The rest of you, if you're still awake, finish reading, then go watch A.D.

The premise is really quite simple, being a marriage of TDD, design patterns, and, crucially, You Ain't Gonna Need It. All you do is start coding to your requirements, doing the simplest thing that will get the job done. When you start seeing patterns, apply them via refactorings. With Eclipse this is so easy it's laughable. The important thing is to resist applying a design pattern until the need for it asserts itself.

"You dork," you may be saying. "So, if I'm building a web app in Struts, I should eschew MVC until I can prove I need it?" Naw. MVC is like a meta-pattern anyway. But even trying to resist prematurely applying patterns can lead to some enlightening moments. The code I've written this week is the lightest, most elegant, well-structured code I've ever coughed up. So I'm floating on a pink cloud, and eventually the honeymoon will end. But right now I'm stoked on this refactor-to-patterns approach. Give it a try if you get a chance.

Hey I like A.D.

It makes me feel like my life isn't so complicated after all.

I have probably done that without even knowing about it. I start coding, then go .. AH ha! then redo it in a pattern.

The key is

having tools and/or practices that support and make the task easier. Obviously Eclipse is one of the favorites for this sort of thing and incredibly useful, but there are lots of others out there.

A tool that can tell you "Yes, this code has the same fingerprint now as it did before" is the safety net.

What do you mean

What do you mean by:

"A tool that can tell you "Yes, this code has the same fingerprint now as it did before" is the safety net."

I mean

If you have something check your code before and after that can confirm that the code gives the same results (regardless of how) for given inputs before and after your change, you're all set.

How the code works underneath is irrelevant.

Wouldn't that be ... unit

Wouldn't that be ... unit tests? :)


Not that I'm a Unit Test bigot or anything. ;)

But without it refactoring is a much riskier exercise.