Search code examples
ooprepository-patternsemanticsaggregationpoeaa

What are the differences between Object Collections, Object Aggregates, Object Associations, and Object Composition?


I'm seeing these terms used and I'm thinking my own usage of them may be incorrect. I'm wondering exactly how they are different.

Object Collection - ???

Object Aggregation - ???

Object Association - ???

Object Composition - ???

It seems these terms come up lately when talking about ORMs, Data-mappers, and Repositories. For example, Fowler mentions object collections here. What do these terms mean specifically, and how should I use them effectively in speaking?


Solution

  • Object Collections

    Is a more broader term, than "arrays", but, includes "arrays". Collections are objects by themselves, its main goal is to store several other objects, plus other features that depends on each collection kind, such the order of insertion, or order of extraction, if duplicated items are allowed, and so on.

    Object Association

    Is also, a very generic term, it implies there is a conceptual relationship between 2 objects. There are also, several kinds of "associations", with more specific goals.

    Object Aggregation

    Is an object association in which an object is related to another object. They can exist independently, and the creation or destruction of one, does not affect the other one, although some operations are result of the interaction of both objects.

    Object Composition

    Is an object association in which an object is part of another main object. The sub-object cannot exist independently, usually, it's creation or destruction, its managed by the main object.

    Note:

    Note: Object Aggregation and Object Composition are kinds of Object Association (s), but, there are not the only ones.