Composite Pattern

9

Click here to load reader

description

An overview of the Composite Pattern form the GoF book.

Transcript of Composite Pattern

Page 1: Composite Pattern

Structural Patterns - Composite

Melbourne Patterns Group July 1 2009Chris Bushell

Page 2: Composite Pattern

Intent

Allow clients to treat primitive objects and containers in the same way

Page 3: Composite Pattern

Graphics Example

• Line

• Rectangle

• Text

etc.

Page 4: Composite Pattern

Graphics Example Continued

GraphicLineRectanglePicture

LineRectangle

Page 5: Composite Pattern

Recursive Composition

Page 6: Composite Pattern

Puzzle Example

Page 7: Composite Pattern

Participants

• Component

• Leaf

• Composite

Page 8: Composite Pattern

Participants

Page 9: Composite Pattern

Code