This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes OO, Patterns, UML and Refactoring and the fly likes decorator design pattern Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "decorator design pattern" Watch "decorator design pattern" New topic
Author

decorator design pattern

cherry hal
Greenhorn

Joined: May 06, 2012
Posts: 10
Hi,
Anybody can tell me about decorator designpattern
Punit Jain
Ranch Hand

Joined: Aug 20, 2011
Posts: 939
To extend or modify the behaviour of ‘an instance’ at runtime decorator design pattern is used.
Inheritance is used to extend the abilities of ‘a class’.
Unlike inheritance, you can choose any single object of a class and modify its behaviour leaving the other instances unmodified.
i mean if you use inheritance and extend super class to sub class, then say, you created 100 objects of that class, your class functionality will be in all the 100 objects.
but you want that functionality in 2 or 3 objects that time you can decorate that object run time, that is where decorator pattern is used.
Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 7081
    
  16

cherry hal wrote:Anybody can tell me about decorator designpattern

It'd be too much to put here, but this might help.

Otherwise: Do you have a specific question about the pattern? Or something particular that you don't understand?

Winston


Isn't it funny how there's always time and money enough to do it WRONG?
Artlicles by Winston can be found here
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: decorator design pattern
 
Similar Threads
Decorator design pattern
Is this a design pattern?
List of Patterns used in Java SE
EJB and pattern
Decorator Pattern ??