This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
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.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!