views:

132

answers:

8

Hi You know, some of the GOF patterns like Singleton or prototype are pretty simple. But some of them like factory method is clearly complicated.

What is your advise for understanding them quickly?

Thank you

A: 

Research.

Read lots of descriptions, find lots of examples.

ck
+7  A: 

Try reading Head First Design Patterns first. You'll find it's a much gentler introduction if GOF is over your head.

Josh
+1  A: 

Read this

Maurice Perry
+1  A: 

Anyway if you decide to read GOF book. Code the examples from the book. Practice a lot, then things get easier and easier.

Gadolin
+2  A: 

Try out this SO link for examples. It worked great for me..

Oren A
+1 wonderful link :)
odiseh
+1  A: 
  1. You need to get the theoretical understanding, what's the reasoning about and mainly when a given pattern should be applied.
  2. Code your own example. You need to practice. Based on my experience you don't understand a pattern (deep enough) until you first had to use it in practice.

Note, never try to force yourself to implement a pattern, just because you want to have it or 'cause it seems to be "cool" to use it. In most of such cases it will just add complexity. A pattern should naturally fit into your code and give you benefits such as reusability, higher testability, better maintainability,...

Generally speaking though, I find that learning patterns increases your coding skills dramatically.

Have fun

Juri
+1  A: 

Design Patterns can be complex and I have met a lot of people who have misunderstood some details as they could not see the diffence between some patterns and where to use them.

You can learn much from books, casts or tutorials on the web. Any programming language or some best pracices on tools, go for the web. But on Design Patterns, look for a senior developer, who has some time. Talk with him, let him explain. Show him some code and ask him, which pattern could make your life easier in future. This helps you probably more than reading books.

Stefan Papp
+1  A: 

I've been saying this the last few days a lot, but read these 2 ebooks, plenty of good info on how to design/develop/improve code.

imho the reason why is so easy to struggle with all the different patterns, is when you see them as a lot of unrelated pieces with no shared goal. The above ebook on SOLID is more about the principles involved, so you can see a clear story on what you gain.

eglasius