27 AGGREGATE ENFORCER
In general, classes are designed to carry related data and offer focused functionality. Sometimes an object may contain other objects as part of it. Such an object, which is a union of other objects, is called an aggregate object. For example, a computer is an Aggregate object that contains other objects such as a CPU unit and memory units. The Aggregate Enforcer pattern recommends that when an Aggregate object is constructed, it must be constructed in full. That means that when an Aggregate class is instantiated, all of its member variables representing the set of constituting objects must also be initialized. The idea is to make sure that an Aggregate object is created in full or is not created at all.
Get Software Architecture Design Patterns in Java 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.