0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Composite Pattern(in progress)

Last updated at Posted at 2018-05-17

Composite Pattern

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

exa.md
- CEO
  - 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.

Reference

0
0
0

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
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?