There are loads of design patterns created over the years. Java API has some of them "built - in". I mean, the only one i am aware of is the Observer with Observable interface etc.
So my question is: where could i find other built in patterns in Java. I looked in the API for Decorator, Factory Strategy but nothing came up. Is Observer the only one supported "officialy"?
Java Patterns
Page 1 of 13 Replies - 258 Views - Last Post: 02 July 2012 - 12:28 PM
Replies To: Java Patterns
#2
Re: Java Patterns
Posted 02 July 2012 - 11:41 AM
The Singleton pattern is implemented. Notice how certain classes like Calendar have a getInstance() method. The XML parsing API implements a factory pattern as well. Enums allow support of the multiton pattern.
#3
Re: Java Patterns
Posted 02 July 2012 - 12:08 PM
I'm afraid you might be misunderstanding design patterns. They're just ideas, just ways to structure your code. They're not like algorithms or data structures. So you'll find plenty of places in the java libraries where people use this or that pattern, but none of them are "supported" by java. There's Observer, as you say, and there's FileVisitor, and lots of Factories, but these are just people solving their particular problems with patterns, often using the name in their solutions.
If you're building something and you want to use a particular pattern, you still have to understand its advantages and drawbacks and how it's constructed, and construct it. Sometimes there will be a class that'll help you out, like Observer, but that's not the pattern. It's just a tool for implementing the pattern.
If you're building something and you want to use a particular pattern, you still have to understand its advantages and drawbacks and how it's constructed, and construct it. Sometimes there will be a class that'll help you out, like Observer, but that's not the pattern. It's just a tool for implementing the pattern.
#4
Re: Java Patterns
Posted 02 July 2012 - 12:28 PM
I have studied patterns last year but it was only done in theory. No programming involved. But i agree with your point about advantages drawbacks etc.
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote






|