Understanding association
An association models a relationship that exists between otherwise unrelated class types. An association can provide ways for objects to interact to fulfill these relationships. Associations are not used for Has-A relationships, however, in some cases, there are shades of gray as to whether we’re describing a bonafide Has-A relationship, or whether we are merely using the phrase Has-A because it sounds appropriate linguistically.
Multiplicity for associations exists: one-to-one, one-to-many, many-to-one, or many-to-many. For example, a Student
may be associated with a single University
, and that University
may be associated with many Student
instances; this is a one-to-many association.
Associated objects have an independent existence. That is, two or more objects may be instantiated and exist independently for a portion of the application. At some point, one object may wish to assert a dependency or relationship with the other object. Later...