Understanding Whole-Part Systems

A Whole-Part system has two types of participants:

  • Whole: The whole is the aggregation of the smaller objects that are the parts. This grouping of parts provides a way to access part-specific functionality and provide some functionality that is available only to the whole.

images A car is made from parts

A real-world example of the Whole-Part pattern is a car. The car has many parts invisible to the driver. While the car is running, fuel is being supplied to the cylinders by the fuel injector, electricity to generate a spark in the spark plug is being provided by the distributor, and they're being combined in the piston. When the spark arrives and there's fuel present, the piston will be moved to generate mechanical power. Each of these parts — fuel injector, spark plug, distributor, and piston — is a separate part within the whole of the car. The driver is the client of the system.

This whole-part design of the system simplifies changing individual parts and allows the parts to be reusable in different wholes (different cars). Each of the parts can be engineered to be very good at its responsibilities.

A whole may provide ways to access parts' functions. Also, a whole can have its own functionality, perhaps combining functionality from the parts into something new.

  • Parts: Parts are contained in only — and exactly — one whole at a time. Multiple ...

Get Pattern-Oriented Software Architecture For Dummies now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.