Design Patterns
  • Introduction
  • Proto-Pattern
  • Anti-pattern
  • OO Design Principles
  • Classification
  • Creational Design Patterns
    • Singleton
    • Factory
    • Abstract Factory
    • Builder
    • Prototype
  • Structural design patterns
    • Adapter
    • Bridge
    • Composite
    • Decorator
    • Facade
    • Flyweight
    • Proxy
  • Behavioural Design Pattern
    • Chain of Responsibility
    • Command
    • Interpreter
    • Iterator
    • Mediator
    • Memento
    • Observer
    • State
    • Strategy
    • Template Method
    • Visitor
  • Concurrency Design Pattern
  • Architectural Design Pattern
  • Modern Desing Patterns
Powered by GitBook
On this page

Was this helpful?

  1. Structural design patterns

Composite

A tree structure of simple and composite objects.

PreviousBridgeNextDecorator

Last updated 5 years ago

Was this helpful?

  • Composite pattern allows you to have a tree structure and ask each node in a tree structure to perform a task.

  • creates a tree structure of group of object.

  • It is used where we need to treat a group of objects in similar way as a single object.

  • composes objects in in term of tree structure to represent part-hole hierarchy.

  • This tree is constructed with leaf (no children - represents leaf) and composite (has collection of child components - represents branch).

  • Most frequently used in JavaScript.

Part-Hole Hierarchy