Solly
Lesson

Vocabulary: Composite

Vocabulary after construction: Composite

The previous exercise began with Expected Behavior and design pressure, not with this name.

The structure that emerged is traditionally called Composite.

What the reasoning established

  • Stable role: Every component supplies total().
  • Change pressure: Leaf kinds and tree shape can grow independently of consumers.
  • Ownership/lifetime when relevant: The tree owns child references; leaves/groups can be composed at the boundary.
  • Structural consequence: Containers hold child components through the same role used by leaves.
  • Runtime topology: A group recursively asks each child for total().

Nearby distinction

Decorator: Composite represents recursive part/whole topology; Decorator wraps one component to add behavior.

Simplify

Ask whether any abstraction can be removed while preserving the original acceptance behavior and design-stress property. If yes, prefer the simpler design.

Use the pattern name to communicate a structure you can already justify. Do not use the name as a recipe that replaces requirements analysis.

Sign in with an enabled provider to save your lesson progress.
Sign in to track progress

Loading sign-in options…