Whole Part Pattern

The Whole-Part design pattern helps with the aggregation of components that together form a semantic unit. An aggregate component, the hole, encapsulates its constituent components, the Parts, organizes their collaboration, and provides a common interface to its functionality. Direct access to the Parts is not possible, however, it is necessary for Parts to interact sometimes.

We usually need a component that encapsulates smaller objects, and prevents clients from accessing these constituent parts directly. Define an interface for the aggregate that is the only means of access to the functionality of the encapsulated objects. allowing the aggregate to appear as a semantic unit.

The general principle of the Whole-Part pattern is applicable to the organization of three types of relationship:assembly-parts, container-contents,collection-member.

Related Patterns:
Composite and Facade. However facade structure does not enforce the encapsulation of Parts; clients may also access them directly, facade does not compose complex services from simpler services; they only perform necessary interface translations and request forwarding.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License