SENG 365 — Software Engineering
2026-07-24
Reading: Robillard, 3rd ed. — Ch. 6, Composition (pp. 125–156).
Team aggregates Players; the team’s points are the sum of player points.Groups of objects behave like single objects.
Think of folders vs. files: ls doesn’t differentiate, except folders contain children.
ProgramMovie, DoubleBill, NullShowCompositeShowName: Composite · Intent: treat groups of objects as a single object.
null everywhere, a null object does a no-op.A point-of-sale system for a coffee shop. Basic beverages, but customers customize (milk, syrup, …).
MultiDrink with switch statements → a God class with multiple responsibilities.Name: Decorator · Intent: attach additional responsibilities to an object dynamically.
cost(), draw()).Show.clone().clone() judiciously.”Change the default class at runtime where the type can’t be known ahead of time.
Deck), support dynamic switches (setPrototype).Command holistically — to support undo, GUI mapping, macros.draw()) their own objects.aFoundations.getPile(FIRST).getCards().add(pCard); requires too much knowledge of other classes.
Neil Ernst ©️