This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Joe Nguyen
Ranch Hand
Posts: 161
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic