Presentation is loading. Please wait.

Presentation is loading. Please wait.

Composite Design Pattern By Aravind Reddy Patlola.

Similar presentations


Presentation on theme: "Composite Design Pattern By Aravind Reddy Patlola."— Presentation transcript:

1 Composite Design Pattern By Aravind Reddy Patlola.

2 Composite Design Pattern
What is it? Compose objects into tree structures to represent part-whole hierarchies. Composite lets clients treat individual objects and compositions of objects uniformly.

3 Participants Component – An abstract base class that declares the interface for objects in the composition. Client – Manipulates objects in the composition thru component interface Leaf – A subclass that defines behavior of primitive objects in the composition Composite – A subclass that defines behavior for components having children.

4 Structural Representation of a Participants

5 Example

6 General Structure of Composite

7 Node Structure

8 Object Structure

9 When to use Composite? When you want to represent part-whole hierarchies of objects. When you want client to ignore the difference between compositions of objects and primitive objects

10 Advantages Makes the client simple, by treating primitive and composite objects uniformly. Makes it easier to add components. Disadvantages Makes design overly general i.e., components of a composite cannot be restricted.

11 References: Design Patterns – Elements of Reusable Object Oriented Software by Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides. composite/composite.PDF


Download ppt "Composite Design Pattern By Aravind Reddy Patlola."

Similar presentations


Ads by Google