It's not a secret anymore!
The moose likes OO, Patterns, UML and Refactoring and the fly likes Design Patterns - when and why? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "Design Patterns - when and why?" Watch "Design Patterns - when and why?" New topic

Design Patterns - when and why?

Kameswari Jyosyula
Ranch Hand

Joined: Feb 20, 2001
Posts: 39
I would like to know as to why one should use design patterns and what design patterns are mostly used in the industry.Also, how is the usage of these design patterns decided - like when to use the factory pattern etc..
Could someone shed light on this please.
I am going through some good books on them but would like a heads up in this.
Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
Read the GoF book! The idea is that there are certain groups of problems that are common to most programming efforts. Once a pattern has been discovered that can solve that problem, programmers should use that pattern instead of constantly "reinventing the wheel."

Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
Gavin Hogan

Joined: Feb 01, 2001
Posts: 3
Really an old (generally informal) practice that's getting some formal attention. But from what I've read on it so far (admittedly limited), it is difficult and takes time and familiarity with the topic to understand when and how to apply a given pattern. My preference would be to attend a hands-on workshop with someone who's been working with them for quite a while.

Gavin Hogan
Frank Carver

Joined: Jan 07, 1999
Posts: 6920
One of the best ways to familiarize yourself with patterns is to read code, lots of it, both good and bad. Keep a good patterns book handy, and try to work out what patterns have been used where, and why (or why not). Some source code is available with comments or dicuments describing which pattersns were used and why (check out JUnit, for example).
Think about design patterns in real world terms, and look for them in everyday processes. You will start to see them everywhere ...

Read about me at ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
John Wetherbie

Joined: Apr 05, 2000
Posts: 1449
The only really new thing about patterns is that they are now being formally (or informally) documented. But what a change that is!
One approach I used to learn the GoF patterns was to pick one pattern (or more) a week, read its section in the book and then code up the code from the book or come up with an example that used the pattern. This allowed me to get at least some feel for the pattern. Doing design and coding, or looking at designs and code, are also a good way to see how patterns can be used (and abused).

The only reason for time is so that everything doesn't happen all at once.
- Buckaroo Banzai
I agree. Here's the link:
subject: Design Patterns - when and why?
It's not a secret anymore!