This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes OO, Patterns, UML and Refactoring and the fly likes How to identify whether decorator pattern is used by looking at API Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "How to identify whether decorator pattern is used by looking at API" Watch "How to identify whether decorator pattern is used by looking at API" New topic
Author

How to identify whether decorator pattern is used by looking at API

Joe Nguyen
Ranch Hand

Joined: Apr 20, 2001
Posts: 161
What is the good way to identify whether decorator pattern used by looking at the API? Besides the abstract decorator has the same type as the Abstract Component, the abstract decorator also contains an instance of the Component (composition). If the Decorator does not contains the instance, ConcreteDecorator needs to contain an instance of the component. What is the best way to recognize decorator pattern?
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
I just read the Head First Design Patterns Chapter on Decorators and thought it was great! One thing you might see in the API is a constructor that takes an argument extending the same abstract type as the class you're constructing. If you can get into the code, you'd also see the decorator passing some or all methods on to the class it's decorating.


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How to identify whether decorator pattern is used by looking at API
 
Similar Threads
decorator pattern from HFDP
here we go again - design patterns from hell
Design Patterns...
URLybird (1.3.1): should i use lock/unlok for update in non-network mode?
Constructors in abstract classes