Presentation is loading. Please wait.

Presentation is loading. Please wait.

Fall 2009ACS-3913 Ron McFadyen Composite Pattern Problem: How do we treat a composition structure of objects the same way as a non-composite object? Arises.

Similar presentations


Presentation on theme: "Fall 2009ACS-3913 Ron McFadyen Composite Pattern Problem: How do we treat a composition structure of objects the same way as a non-composite object? Arises."— Presentation transcript:

1 Fall 2009ACS-3913 Ron McFadyen Composite Pattern Problem: How do we treat a composition structure of objects the same way as a non-composite object? Arises in POS because there may be multiple co-existing pricing strategies, and we prefer if Sale does not know if there’s one or many Solution: define classes for a composite structure A composite is a group of objects in which some objects contain others; one object may represent groups, and another may represent an individual item, a leaf.

2 Fall 2009ACS-3913 Ron McFadyen Composite Used to compose objects into tree structures to represent part-whole hierarchies Composite lets clients treat individual objects and compositions of objects uniformly

3 Fall 2009ACS-3913 Ron McFadyen Composite Component declares the interface for objects implements default behavior Leaf represents leaf objects in the composition. has no children. defines behavior for primitive objects in the composition. Composite defines behavior for components with children stores child components implements child-related operations Client manipulates objects using the interface

4 Fall 2009ACS-3913 Ron McFadyen Composite Pattern Consider figures 26.14, 26.15 on page 454-5


Download ppt "Fall 2009ACS-3913 Ron McFadyen Composite Pattern Problem: How do we treat a composition structure of objects the same way as a non-composite object? Arises."

Similar presentations


Ads by Google