3.8. Association

Whenever we create a class, such as Student or Professor, in which one or more of the fields are themselves references to other objects, we are employing an OO technique known as association. The number of levels to which objects can be conceptually bundled inside one another is endless, so association enables us to model very sophisticated real-world concepts. As it turns out, most "interesting" classes employ association.

With association, it may seem as if we're nesting objects one inside the other, as depicted in Figure 3-8.

Figure 3.8. Conceptual object "nesting"

Actual object nesting (that is, declaring one class inside ...

Get Beginning C# 2008 Objects: From Concept to Code now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.