Design Patterns - Why and How

by Erik Lane 12. September 2005 02:03

I will be honest and say that I haven't knowingly used a Design Pattern.  Although I read a lot about them and have attended a meeting on them, I guess I just don't know enough so I can be on the lookout to implement them.  I really do like the thought of having "a general solution to a common problem in software design" or a "description or template for how to solve a problem that can be used in many different situations".  Those are the things that are appealing to me.

You read posts and articles that point out the good things and yet still say that they shouldn't be used unless it is necessary.  I agree that added complexity for the sake of complexity isn't a good thing.  I don't know about you but I can learn more by writing code than by reading about it - don't get me wrong, reading is very important and should done too.  Most times I will start off by reading but then I will hit the IDE to get my feet wet and store it away for a time when I can use this new piece of knowledge...whatever it is.  Then why and how should I learn them?

I'm about ready to get another book to read and I've been wanting to get Head First Design Patterns.  I've read that it is solid on content and easier to read than similar books on the subject.  Then I read the review over at Coding Horror.

 "Beginning developers never met a pattern or an object they didn't like. Encouraging them to experiment with patterns is like throwing gasoline on a fire. And yet that's exactly what this book does."

So which is it?  Experiment and learn or stay in the dark and not get any better?  I'm sure there is a compromise in there somewhere.  Jeremy D. Miller had previously blogged questioning why design patterns aren't common knowledge.  He received some good feedback and to help all of us out he is starting a series of posts over the next few months on Learning About Design Patterns.

 Why - "Thinking and learning about design patterns is a great way to learn the ins and outs of Object Oriented Programming...."
 How - "Write code.  Do some sort of nontrivial, personal coding project where you can freely experiment with design patterns..."
 

I think somewhere in there is a compromise between throwing gas on the fire and never lighting the match.  Jeremy's first installment is out - Dynamic Behavior with the Decorator Pattern.

Tags:

Comments

Jeff Atwood
Jeff Atwood on 9/12/2005 5:54:00 AM

There's nothing wrong with the book, but it's definitely backwards.

Read the book in the reverse order. Start with pages 593+, then loop back to the beginning.

I also don't like the way the examples are so contrived as to be useless. It's hard to relate to examples that are so abstract and silly. Unless you happen to be running a gumball machine factory, I guess.

I'm all for humor, but I would have preferred something closer to the way the patterns will be used in the real world.

eriklane
eriklane United States on 9/12/2005 6:25:00 AM

Thanks Jeff.  I agree that closer to "real world" examples go a lot further in the long run.  I may just start at 593.  Thanks for your review.

Comments are closed