Aggregate Enforcer Pattern

The Aggregate Enforcer (AE) pattern (I have seen debates if this is a design pattern or not) recommends that when an Aggregate object is constructed, it must be constructed in full, that is, 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.

There are two types of aggregate relationships: aggregation (loose) and composition (strong).

public class AggregateClass {//A simple aggregate class
private ABC abc;
private DEF def;
...
...
}

A member variable of an aggregating class (above) can be initialized in two ways:

1- At the time of creating the aggregate object (i.e. in constructor) which is called early initialization. This is AE pattern.
2- On demand (when needed) and we should check for previous existence, etc. This is proxy pattern.

This pattern was defined in software architecture design patterns in java by Partha Kuchana.

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