Aggregation pattern
In object-oriented programming, the aggregation pattern refers to an object that owns or is responsible for an array of objects and defines special behavior for that particular type of array.
Features
The aggregation pattern is useful in situations where code gets more complicated over time and certain characteristics need to be guaranteed for a particular array of objects.
Encapsulation
The aggregation pattern provides a way to encapsulate an array of objects inside another object with an interface for that particular type of array.
Effort
The aggregation pattern requires time and effort to write wrapper methods for all of the common array operations. In most cases, however, not all of the array operations are needed.
Performance
The aggregation pattern provides a way to optimize algorithms when performing common array operations, such as sorting or searching the array. For example, the array primitives built into LabVIEW do linear search on an array because LabVIEW has no way of knowing whether a given array is sorted or not. If the array is always sorted, a binary search is much faster.
External links
- Aggregate pattern on Wikipedia
- Applying Common Object-Oriented Design Patterns to LabVIEW: Aggregation Pattern by Elijah Kerry