• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 161
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic