The decorator pattern participants are:
  • Component: CableTV declares the common cost and packages queries, so clients can use both basic and decorated accounts through one object interface.
  • Concrete component: BasicPlan supplies the initial price and package description.
  • Decorator: the abstract Packages class stores a component reference and forwards its operations, enabling recursive object composition.
  • Concrete decorators: Movies and HDChannels override the queries to add one responsibility while preserving the wrapped component's behavior.
  • Client: an application chooses the nesting of components and observes the resulting account through CableTV.
Each wrapper contributes its price exactly once along the chain. The same structural arrangement handles a new optional package without changing the existing component interface.

Articles by others on the same topic (0)

There are currently no matching articles.