The Pragmatic Craftsman :: Simplicity from complexity : by Stanley Kubasek ::

Learning GoF Design Patterns and Refactoring

To learn design patterns is not easy. It’s one thing to just read about them and think you know them. It’s another thing to actually know how to use them, and to remember them as time passes by. I must admit, there is only a couple of the GoF patterns I remember. I read about them and after a while I forget them. However, that might be changing, as I have a different approach: I read several books on patterns at the same time.

A while back, I read Robert Martin’s Agile Software Development, Principles, Patterns, and Practices (a great book). I also read portions of the first edition of Design Patterns Explained (ok), portions of the classic Design Patterns, and the whole Holub on Patterns (I did not like it at all). I own all of the books I mentioned (except Holub on Patterns). And I recently bought Refactoring to Patterns by Kerievski. This latest book is what prompted me to change how I study design patterns. (I also own Martin Fowler’s Refactoring, which is a classic book that every developer should have by his side.)

I started reading Refactoring to Patterns. So far, about a third into the book, the book is very good. But I feel that the design patterns are starting to click. Why? As you might guess, the book tries to combine Fowler’s Refactoring and the GoF’s Design Patterns. So, whenever I read about a particular refactoring, I jump into Martin’s book. Not only that helps me understand the text better, I also get more info about the refactoring. (Plus, you get some good advice from Fowler, which I admire as a developer.) Same with patterns, whenever he mentions a GoF pattern (almost every refactoring), I go to the Design Patterns book.

However, the GoF book is not easy, and the book by itself is not enough sometimes. That’s when I turn to Robert Martin’s book, which contains simple Java code for a lot of patterns he mentions. And because he doesn’t mention all of them, I hit the web. This site, Design Patterns, contains code about all GoF patterns — very good resource.

And if that was not enough, I try to write practice code in Eclipse. I created a learn patterns project, and I create a new package for each pattern. This is very useful when, down the road, you forget about the pattern and want a quick reminder (I learn by example). Design patterns are hard to learn because we don’t get to use them right away. By practicing them, you see them in real world. You see them from a different angle. This is very valuable.

Have I found the ultimate solution for learning patterns. I don’t think so. But it makes a big difference to me. Yesterday, I learned about a Composite pattern, today I learned about the Boulder pattern. And I think the knowledge is deeper this time. I think this is a very good way. Little more involved and time consuming, but at the end, it’s what stays with you. Try it and learn. :-)

Favorite Quote

Topics

Tags

Archive

Currently Reading

Info

© 2001-2024 Stanley Kubasek About me :: Contact me

Me on Twitter

»see more

Recent Entries