A: 

It's very much about ownership and visibility. There are different names for these relationships, but you should consider these two points:

  • Does the parent have strict ownership over the child, such that when the parent dies, the child should die also?

  • Is the child visible to other entities besides the parent?

Answers to these questions will help you clarify these relationships.

David M. Karr
+1  A: 

Holding another class means that a class is associated with another class through a parent child relationship. For example a Path has a list of points. The Path is the parent of the List of Points which is the parent of the individual points.

Aggregating means taking different classes and putting them behind a interface so they appear as one class. For example a FileDialog will have several button class, a text input class, a listview/treeview class and so on. But to the rest of the system it just had methods to be activate, maybe assign a default filename, and retrieve the rest.

The fact it is comprised of all the other classes is immaterial to other classes using it as a filedialog.However it works by aggregating all the classes to perform the expected behavior.

RS Conley
+1  A: 

IMO, if I understood correctly, you are asking for a definition of Composition vs. Aggregation. Aggregation or holding is a collection of entities. Composition has a tighter constraint. Think of average marks awarded to student: when we compute an average, we cannot exclude any item. Composition is similar to this. No item can be missed out. Aggregation on the other hand is more loosely defined.

An interesting analogy would be that of a quiver full of arrows and a car. A quiver is an Aggregation of arrows, quiver can exist without arrows; Car is an Composition (Sum of parts). And lets not argue that a car without a wheel is still a car :)

As for references: http://www.bletchleypark.net/algorithms/software/oop.html

questzen