The Composite Pattern

1 / 11

# The Composite Pattern - PowerPoint PPT Presentation

The Composite Pattern. Commissioner (No Twins, Expos). Owners (No Twins, Expos). Managers (No Twins, Expos). Congress (No Twins, Expos). Media (No Twins, Expos). Players (No Twins, Expos). Radio (No Twins, Expos). Television (No Twins, Expos). FireworksGuy (Show). Fireworks

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.

## PowerPoint Slideshow about 'The Composite Pattern' - mieko

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

### The Composite Pattern

Commissioner

(No Twins, Expos)

Owners

(No Twins, Expos)

Managers

(No Twins, Expos)

Congress

(No Twins, Expos)

Media

(No Twins, Expos)

Players

(No Twins, Expos)

(No Twins, Expos)

Television

(No Twins, Expos)

FireworksGuy

(Show)

Fireworks

(Show)

Flare

(Show)

Star

(Show)

Display

(Show)

Structural Patterns
• Concerned with how classes and objects are combined to create larger structures.
Structural Object Patterns
• Are concerned with composing objects to establish new functionality.
Composite Pattern
• Facilitates the composition of objects into tree structures that represent part-whole hierarchies.
• These hierarchies consist of both primitive and composite objects.
Observations
• The Component (Graphic) is an abstract class that declares the interface for the objects in the pattern. As the interface, it declares methods (such as Draw) that are specific to the graphical objects.
• Line, Rectangle, and Text are so-called Leafs, which are subclasses that implement Draw to draw lines, rectangles, and text, respectively.
Observations (Continued)
• The Picture class represents a number of graphics objects. It can call Draw on its children and also uses children to compose pictures using primitive objects.
Concluding Considerations
• The Composite Pattern is used to represent part-whole object hierarchies.
• Clients interact with objects through the component class.
• It enables clients to to ignore the specifics of which leaf or composite class they use.
• Can be used recursively, so that Display can show both flares and stars.
• New components can easily be added to a design.