views:

2137

answers:

20

I have read around 4-5 books on design patterns, but still I dont feel I have come closer to intermediate level in design patterns?

How should I go studying design patterns?

Is there any best book for design pattern?

I know this will come only with experience but there must be some way to master these?

+24  A: 

The best way is to begin coding with them. Design patterns are a great concept that are hard to apply from just reading about them. Take some sample implementations that you find online and build up around them.

A great resource is the Data & Object Factory page. They go over the patterns, and give you both conceptual and real world examples. Their reference material is great, too.

joseph.ferris
+1: Code. Start small. Do something -- anything -- and ask follow-up questions. It's more art than science.
S.Lott
Exactly! I've always been amused that software falls under "Computer Science". I can see the argument for hardware, but software makes for a very inexact science!
joseph.ferris
+3  A: 

Have you tried the Gang of Four book?

Design Patterns: Elements of Reusable Object-Oriented Software

Rohit
I wouldn't recommend that book as an "eye-opening" book :)
Geo
I would recommend it as an eye-closing book. A few pages of this tome before bedtime and your insomnia will be a thing of the past.
Don
+16  A: 
Darren C
It's a little odd at first to be reading through a "serious" book that looks like that, but as I kept reading I noticed that I was actually understanding concepts for a change. Definitely worth a read.
Tim Whitcomb
I definitely think this is the best book for learning about design patterns. The GoF book should be used as a reference, after you understand them better.
Bill the Lizard
I just hate the cover, love the content!
ZiG
LOL, yeah. The whole series uses stock photography. I think it's supposed to be "ironically cool".
Bill the Lizard
I've just realized that despite the fact that I've seen this book praised many times I've never considered buying it, I guess by judging the cover:) It sure is dumb to judge a book by its cover but so is putting a chick photo with myspace angle in the cover of a design pattern book for god's sake!
utku_karatas
that cover has a long story:)"The book isn't the only thing that's backwards: did you know the Head First girl pictured on the front of the book leads a shocking double life? That's right, student by day, stripper by night. Ok, maybe not ..."http://www.codinghorror.com/blog/archives/000380.html
Comptrol
you mentioned you read 3 books..did you read this one as well?http://www.amazon.com/Design-Patterns-Explained-Perspective-Object-Oriented/dp/0201715945if so, what did you think?
ShaChris23
read this book. it's a rule
sunglim
+1  A: 

My suggestion would be a combination of implement a few of them and analyze some implementations of them. For example, within .Net, there are uses of adapter patterns if you look at Data Adapters, as well as a few others if one does a little digging into the framework.

JB King
+3  A: 

Practice practice practice. I think 4 to 5 books is even an excessive reading exercise without some good amount of practising. Best way to do this, I believe, is to start refactoring your current projects using the patterns. Or if you don't have any projects you're actively working on then just do it your own way and then try refactoring to patterns.

You cannot appreciate them fully if you haven't suffered through the problems they solve. And please keep in mind that they are not silver bullets - you don't need to memorize them and push it hard to apply on the fly. My two cents..

utku_karatas
+1  A: 

I have found that it is a bit hard to comprehend or understand the benefits of some patterns until one understands the problems they solve and the other (worse) ways the problems have been implemented.

Other than the GOF and POSA books I have not really read any so I can't give you other recommendations. Really you just have to have an understanding of the problems domains and I think that many less experienced developers may not be able to appreciate the benefits of patterns. This is no slight against them. It is a lot easier to embrace, understand and appreciate good solutions when one has to struggle with poor alternatives first.

Good luck

Tim
+1  A: 

I don't know about best book, but the purists might say Design Patterns: Elements of Reusable Object-Oriented Software

As far as my personal favorite, I like Head First Design Patterns published by O'Reilly. It's written in a conversational voice that appeals to me. When I read it, I reviewed my source code at the same time to see if it applied to what I was reading. If it did, I refactored. This is how I learned Chain of Responsibility.

Practice - Practice - Practice.

Jason Slocomb
+3  A: 

Practice, practice, practice.

You can read about playing the cello for years, and still not be able to put a bow to instrument and make anything that sounds like music.

Design patterns are best recognized as a high-level issue; one that is only relevant if you have the experience necessary to recognize them as useful. It's good that you recognize that they're useful, but unless you've seen situations where they would apply, or have applied, it's almost impossible to understand their true value.

Where they become useful is when you recognize design patterns in others' code, or recognize a problem in the design phase that fits well with a pattern; and then examine the formal pattern, and examine the problem, and determine what the delta is between them, and what that says about both the pattern and the problem.

It's really the same as coding; K&R may be the "bible" for C, but reading it cover-to-cover several times just doesn't give one practical experience; there's no replacement for experience.

McWafflestix
+1  A: 

Lot of good examples have been given. I'd like to add one:

Misapply them. You don't need to do that intentionally, it will happen when you try to apply them in your initial Design-Pattern-fit. During that time every single problem that you'll see will seem to fit exactly one design pattern. Often the problems all seem to fit the same design pattern for some reason (Singelton is a primary candidate for that).

And you'll apply the pattern and it will be good. And some months later you will need to change something in the code and see that using that particular pattern wasn't that smart, because you coded yourself into a corner and you need to refactor again.

Granted, that's not really a do-that-and-you'll-learn-it-in-21-days answer, but in my experience it's the most likely to give you a good insight into the matter.

Joachim Sauer
+1  A: 

For books, I would recommend Design Patterns Explained, and Head First Design patterns. To really learn these patterns, you should look at your existing code. Look for what patterns you are already using. Look at code smells and what patterns might solve them.

David Nehme
+2  A: 

I've lead a few design patterns discussion groups (our site) and have read 5 or 6 patterns books. I recommend starting with the Head First Design Patterns book and attending or starting a discussion group. The Head First book might look a little Hasboro at first, but most people like it after reading a chapter or two.

Use the outstanding resource - Joshua Kereivisky's A Learning Guide to Design Patterns for the pattern ordering and to help your discussion group. Out of experience the one change I suggest to the ordering is to put Strategy first. Most of today's developers have experienced some good or bad incarnation of a Factory, so starting with Factory can lead to a lot of conversation and confusion about the pattern.This tends to take focus off how to study and learn patterns which is pretty essential at that first meeting.

JB Brown
A: 

Design patterns are just tools--kind of like library functions. If you know that they are there and their approximate function, you can go dig them out of a book when needed.

There is nothing magic about design patterns, and any good programmer figured 90% of them out for themselves before any books came out. For the most part I consider the books to be most useful at simply defining names for the various patterns so we can discuss them more easily.

Bill K
A: 

The way I learned design patterns is by writing lots of really terrible software. When I was about 12, I have no idea what was good or bad. I just wrote piles of spaghetti code. Over the next 10 years or so, I learned from my mistakes. I discovered what worked and what didn't. I independently invented most of the common design patterns, so when I first heard what design patterns were, I was very excited to learn about them, then very disappointed that it was just a collection of names for things that I already knew intuitively. (that joke about teaching yourself C++ in 10 years isn't actually a joke)

Moral of the story: write lots of code. As others have said, practice, practice, practice. I think until you understand why your current design is bad and go looking for a better way, you won't have a good idea of where to apply various design patterns. Design pattern books should be providing you a refined solution and a common terminology to discuss it with other developers, not a paste-in solution to a problem you don't understand.

rmeador
A: 

Does anyone know any good books, online docs or even projects where design patterns can be observed in a really nice way? ;-)

I was read Head First patterns and JSP (has a few as well) and they are great, i read tons of wikis, manuals books etc and still dont feel like i have really seen it live and breathing :- )

If anyone knows screencasts, books or docs where real applications design is explained in a walkthrough way that could be great.

A: 

The notion that read design patterns, practice coding them is not really going to help IMO. When you read these books 1. Look for the basic problem that a particular design pattern solves,starting with Creational Patterns is your best bet. 2. I am sure you have written code in past, analyze if you faced the same problems that design patterns aim at providing a solution. 3. Try to redesign/re factor code or perhaps start off fresh.

About resources you can check these

  1. www.dofactory.com
  2. Design Patterns: Elements of Reusable Object-Oriented Software (Addison-Wesley Professional Computing Series) by Erich Gamma, Richard Helm, Ralph Johnson, and John M. Vlissides
  3. Patterns of Enterprise Application Architecture by Martin Fowler

1 is quick start, 2 will be in depth study..3 will explain or should make you think what you learnt in 2 fits in enterprise software.

My 2 cents...

Perpetualcoder
A: 

I would think it is also difficult to study design patterns. You have to know more about OOP and some experiences with medium to big application development. For me, I study as a group of developers to make discussion. We follow A Learning Guide To Design Patterns that they have completed the patterns study. There are C# and JavaScript developers join together. It is fancy thing for me is the C# developer write codes in JavaScript and the JavaScript developer do the same thing for C# codes. After I leave a meeting I also research and read a few books at home to review. The better way to understand more and remember in my mind is to do blogging with examples in both C# and JavaScript in here http://tech.wowkhmer.com/category/Design-Patterns.aspx.

I would suggest first before going to each design patterns please understand the name of patterns. In addition if someone know the concept please just explain and give one example not only just programming but in the read world.

for example:

Factory Method:

Read world: I just give money $5, $10 or $20 and it will produce pizza back without knowing anything about how it produce, I just get a small, medium or big pizza depend on money input so that I can eat or do whatever.

Programming: The client just pass parameter value $5, $10 or $20 to the factory method and it will return Pizza object back. So the client can use that object without knowing how it process.

I'm not sure this can help you. It depends on knowledge level of people join in the meeting.

Vorleak Chy
A: 

Have you read "Design Patterns Explained", by Allan Shalloway.

This book is very different from other design pattern books because it is not so much a catalog of patterns, but primarily presents a way of decomposing a problem space that maps easily to patterns.

Problems can be decomposed into two parts: things that are common and things that vary. Once this is done, we map the common things to an interface, and the things that vary to an implementation. In essence, many patterns fall into this "pattern".

For example in the Strategy pattern, the common things are expressed as the strategy's context, and the variable parts are expressed as the concrete strategies.

I found this book highly thought provoking in contrast with other pattern books which, for me, have the same degree of excitement as reading a phone book.

Phillip Ngan
A: 

I think you need to examine some of the issues you have encountered as a developer where you pulled your hair out after you had to revise your code for the 10th time because of a yet another design change. You probably have a list of projects where you felt that there was a lot of rework and pain.

From that list you can derive the scenarios that the Design Patterns intend to solve. Has there been a time where you needed to perform the same series of actions on different sets of data? Will you need to be able to future capability to an application but want to avoid reworking all your logic for existing classes? Start with those scenarios and return to the catalog of patterns and their respective problems they are supposed to solve. You are likely to see some matches between the GoF and your library of projects.

David Robbins
A: 

For a beginner, Head First Design patterns would do, once we are familiar with all the patterns, then try to visualise the real time objects into those patterns.

Book will help you understand the basic concepts, unless until you have implemented in the real world you CANT Be a MASTER of the DESIGN PATTERNS

harigm
A: 

There is very good Online Video Lecture on Design Patterns

Rachel