Hi, 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. TIA
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."
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.
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 ...
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). John
The only reason for time is so that everything doesn't happen all at once.
- Buckaroo Banzai