Wednesday, March 16, 2005

Caught Josh Kerievsky's tutorial Tuesday. If you missed it--too bad for you! If you missed it and don't have the book, do like the guy who sat next to me: Jump up, run out of the class, and buy it.

Basically, what Kerievsky does is take patterns out of their religious context, saying that of the people who actually get design patterns, too many are "patterns-happy" and want to build them in regardless of need.

The trick is to wait. YAGNI, right? The simplest thing that could possibly work? When the code starts to smell, you'll need to refactor; at that point, consider your refactoring in the context of patterns.

That's the central takeaway from the class, and the book. But it's a biggie.

Note that I said "in the context of", not necessarily "to implement". Kerievsky points out that sometimes, the refactoring just isn't worth it unless you build it to the pattern (although he railed about slavish adherence to the "structure" examples in GoF and other pattern books--you don't have to build every special case and widget in just 'cause it's in the book!). But other times, as you refactor, you get to a point where the smell goes away before you've implemented the official pattern. Stop there. Kerievsky calls that refactoring "towards" a pattern--that's good too. Finally, he shows where you might refactor away from a pattern (the example he showed was converting a Singleton instance to a considerably-simpler inline implementation).

His slides and demos showed lists of smells, relating them to specific refactorings, and showed how to perform the mechanics. Moving, say, embellishments into a Decorator pattern involves multiple refactoring steps, not just one pull of the Eclipse lever, and he gives a good account of how to get there (as well as an appreciation of the process of developing and improving your own).

Me, I've got the book. Actually, I've got two, I keep loaning it out.

6:51 AM

11 comments:

at 8:32 AM Scott W, Ambler said...

Josh has been working on the concept of refactoring to patterns for several years now. A few years back at the XP conference in Sardinia he presented the beginnings of this really good work. I was lucky enough to discuss these ideas with him way back then, and I was so impressed with his work that it motivated the Agile Modeling practice of Apply Patterns Gently (www.agilemodeling.com/practices.htm#ApplyPatternsGently). As Rick said, you need to get his book.

at 6:14 PM alex said...

I appreciate your information on Msdn. I just bookmarked your site and will be back regulalry to keep on top of it. Please check out my blog on Msdn Exposed - I'd really appreciate it

at 2:34 PM Anonymous said...

ASDF is coming soon! Don't be left behind!

at 5:36 PM Anonymous said...

This isn't bad, but I wish there were more folks out there that could provide. Thanks.
-Piano Guru
learn to play piano

at 12:51 PM Anonymous said...

Well done!
[url=http://ndvedtvw.com/xtry/rwdr.html]My homepage[/url] | [url=http://qjauhwcf.com/ehpj/ypiu.html]Cool site[/url]

at 12:51 PM Anonymous said...

Well done!
My homepage | Please visit

at 12:51 PM Anonymous said...

Thank you!
http://ndvedtvw.com/xtry/rwdr.html | http://dqoevrkr.com/tvuo/rkwg.html

at 9:23 AM BuyLevitra said...

Thanks for article!

at 12:15 AM ShopMan said...

I like articles like this. Thanks!

at 4:59 AM Anonymous said...

Thanks for article! Very interesting.

at 1:29 AM Anonymous said...

Do you can write anything else about it? Great article!