The composite pattern
Download
1 / 11

The Composite Pattern - PowerPoint PPT Presentation


  • 150 Views
  • Uploaded on

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

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

PowerPoint Slideshow about 'The Composite Pattern' - mieko


An Image/Link below is provided (as is) to download presentation

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)

Radio

(No Twins, Expos)

Television

(No Twins, Expos)


The composite pattern

FireworksGuy

(Show)

Fireworks

(Show)

Flare

(Show)

Star

(Show)

Display

(Show)



Structural patterns
Structural Patterns

  • Concerned with how classes and objects are combined to create larger structures.


Structural object patterns
Structural Object Patterns

  • Are concerned with composing objects to establish new functionality.


Composite pattern
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
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
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
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.