Download presentation
Presentation is loading. Please wait.
Published byJulian Hunter Modified over 6 years ago
1
Composite Pattern Oct 7, 2003 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
Composite Pattern Generic UML class diagram * Client Component Operation() Leaf Composite Operation() Operation() Other()
3
Composite Pattern Consider a UML class diagram for machines. Machines may be complex and contain other machines. * * 1 PlantFloor MachComponent getMachineCount() 1 Machine MachComposite components: List getMachineCount() getMachineCount()
4
Composite Pattern An object diagram illustrating the machine on floor 5 of the plant floor5 :Plantfloor M1: MachComposite L1: Machine L2: Machine M9: MachComposite L7: Machine L4: Machine
5
Exercise Apply composite to a model for companies. Each company may comprise other companies. Some companies are simple and do not have any structure. Note the general structure for a company is hierarchical – a tree structure. Illustrate the model as a class diagram. Make up two companies; one that is simple and the other a complex tree structure. Illustrate with an object diagram.
6
Illustrate the model as a class diagram.
Exercise See handout from “Software Pioneers” Apply composite to a model for testing programs. Each program is tested by running a number of test cases. A test suite is a collection of test cases. A test suite can be used to test a program. Suppose test suites can be combined to form larger test suites; that is, a test suite may be composed of individual test cases and of other test suites. In general then, a suite of tests for a program looks like a tree structure. Illustrate the model as a class diagram. Suppose you have a program X that has five test cases. Three of these are organized into TestCase1; two are organized into TestCase2. Illustrate the object diagram.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.