3 Replies - 258 Views - Last Post: 02 July 2012 - 12:28 PM Rate Topic: -----

#1 darek9576  Icon User is online

  • D.I.C Lover

Reputation: 195
  • View blog
  • Posts: 1,620
  • Joined: 13-March 10

Java Patterns

Posted 02 July 2012 - 11:40 AM

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"?
Is This A Good Question/Topic? 0
  • +

Replies To: Java Patterns

#2 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 9042
  • View blog
  • Posts: 33,544
  • Joined: 27-December 08

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.
Was This Post Helpful? 1
  • +
  • -

#3 jon.kiparsky  Icon User is online

  • Pancakes!
  • member icon

Reputation: 5437
  • View blog
  • Posts: 8,755
  • Joined: 19-March 11

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.
Was This Post Helpful? 1
  • +
  • -

#4 darek9576  Icon User is online

  • D.I.C Lover

Reputation: 195
  • View blog
  • Posts: 1,620
  • Joined: 13-March 10

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.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1