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

Posts Tagged 'reference'

Learning GoF Design Patterns: References November 16th, 2010

Learning GoF Design Patterns: References

I started learning design patterns a good number of years ago. I learned a few. Probably around half. But others I just kept forgetting. Or I should say, never learned. :(

C’mon, you did not learn design patterns! :)

Knowing design patterns is important. Very important. It’s probably the best “tool” in your toolbox as the developer. Not only the Gang of Four (GoF) patterns, which are the most known, but others as well.

But learning design patterns is hard.

It’s not that the design patterns are hard, it’s the process of learning and retaining that’s hard. Why? If you don’t use it… you’ll forget it.

So a month or two ago, I decided to revisit the subject. I decided to learn the Gang of Four (GoF) patterns. Learn it in a way so I can remember. As I said, not an easy thing to do. (I guess I will really know if I learned it after a few months. :) )

There is probably only one way to really “learn” it. Use it in code. That’s when you see the context, problem, solution, etc. That’s when you really know all the details about the pattern. And most likely it will “stick” with you and you will not forget it.

If you really want to learn a pattern, use it!

If you can…

I have a few that I have used: Observer, Factory, Builder, Singleton, Facade, Strategy, Template Method, Iterator, Command… I think that’s about it.

OK, that’s less than half of the 23 GoF patterns. What happened to the others?

Blame it on my memory.

On the other hand, I don’t want to just use it because it would be cool. It has to be the right fit. And that does not happen often… But when you do see the opportunity, you should be ready!

BE PREPARED

How do you prepare? Here are some ways.

Read the GoF book several times. OK, that might work for you. For others, it probably will not.

Read multiple books. Yes, that’s probably better, but it still could not work for some of the patterns.

Read multiple books and other references at the same time. Yes, I think this is better. Much better. Why? In How To Read A Book the author explains that this is the highest level of reading, Syntopical Reading. By reading multiple authors on the same subject you have trouble understanding, in this case, it might be a particular pattern, you gain the highest level of understanding.

So that’s what I did: I started reading mutliple resources on GoF Patterns at the same time.

Of course, it would be ideal to have ALL the books available on the subject. I don’t. But I have several and that’s a big help. I also have a subscription to Safari (as part of being ACM.org member), and they have a few books there as well. And of course there is the Internet, loaded with many great references.

I started with the classic GoF book. As I read a pattern, let’s say Abstract Factory, I picked up another book or looked at another website. I read a few until I really “got it.” I also looked at code samples. I read some more. Eventually, I got the “aha” moment.

I’d like to share the resources I have used and that I find valuable on the subject of the Design Patterns. Just so your learning will be, let’s say, a bit simpler. :)

It’s already taken me a long time to get to this point. So without further ado, here they are.

BOOKS
Design Patterns by Gamma,Helm,Johnson,Vlissides
There is a reason it’s the classic book. Start your learning from this book. The explanations, reasoning and usages are the best in this book. But it’s not an easy book to read. In fact, I think it’s hard if you’re not a C++ programmer. Still, it’s a great book.

Refactoring to Patterns by Kerievsky
I appreciate this book more now than when I first bought it. Filled with very good advice. However, it only covers a few of the GoF patterns.

Agile Software Development by Martin
My favorite book. Not on Design Patterns in specific, as it also does not cover all GoF patterns, but still worth checking out the few that it does cover.

Head First Design PatternsAvailable on Safari, this book is loved by many, not so by others (including me). But still a great book on the subject.

WEBSITES

Wikipedia: Design Patterns
More than anything, it contains great examples.

dofactory
(claims to be #1 in design patterns). Valuable resource.

Houston Design Patterns
Great resource on design patterns.

Examples of GoF Patterns
Lists places in the JDK where the patterns are implemented.

INDIVIDUAL PATTERNS

Bridge vs Strategy
If you get stuck like I did, check out this url.

Factory Method
Good examples on how to implement the pattern.

Favorite Quote

Topics

Tags

Archive

Currently Reading

Info

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

Me on Twitter

»see more

Recent Entries