aspose file tools*
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 Spring in Action this week in the Spring 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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to identify whether decorator pattern is used by looking at API