More than 3 years have passed since last update.

posted at

updated at

Composite Pattern(in progress)

Composite Pattern

composes objects in term of a tree structure to represent part as well as whole hierarchy

  - Sales Manager
     - Sales Staff A
     - Sales Staff B
  - Technical Manager
     - Engineer A
     - Engineer B 

The Composite Pattern has four participants:

  1. Component
    Component declares the interface for objects in the composition and for accessing and managing its child components. It also implements default behavior for the interface common to all classes as appropriate.
  2. Leaf
    Leaf defines behavior for primitive objects in the composition. It represents leaf objects in the composition.
  3. Composite
    Composite stores child components and implements child related operations in the component interface.
  4. Client
    Client manipulates the objects in the composition through the component interface. Client use the component class interface to interact with objects in the composition structure. If recipient is a leaf then request is handled directly. If recipient is a composite, then it usually forwards request to its child components, possibly performing additional operations before and after forwarding.


Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
What you can do with signing up