Relationship among the classes

a. Association

When a two class are connected to each other in any way, an association relation is established.

An association is a simple structural connection between classes, assumed to be bidirectional, which means that we can navigate from either class to the other one.There are two basic kind of association:

i. Binary association and,

ii. N-ary associations.

A binary association: which exists between two classes,

N-ary association: which exists among three or more classes, appears as a set of lines connected to a central diamond,

b. Aggregation

When a class is formed as a collection of other classes, called an aggregation relationship between these classes. It is also called a “has a” relationship.

In other word, an aggregation is a special kind of association a” whole/part”. Within which one or more classes are the parts of a larger whole.

An aggregation appears as a line with an open diamond at one end. In this case, a contact group is a virtual grouping of contacts; a contact may be included in more than contact group. If we delete a contact group, no contact will be deleted.

c. Composition

Composition is a “strong” form of aggregation. There are two different between composition and regular aggression as follow.

– Within a composition relationship. The whole and parts have coincident lifetime. This means that if a particular instance of the whole is destroyed, parts will be also destroyed with it.

– A class can only belong to one composition relationship at a time as a part.

A black diamond represents composition. It is placed on the address book class because it is Address book that is composed of contacts. Composition is a whole / parts relationship. In this case, address Book is a whole and contact is a part of Address Book. Composition also indicate that lifetime of part is dependent on the whole. This means if address book is destroyed, contact will also be deleted with it.

d. Generalization/Inheritance

This kind of relationship is called “Is-a” relationship because the child class is a type of parent class. Generalization is used to define reusable elements in a class diagram.

A Generalization appears as a line with an open triangle on one end.

e. Realization / Interface

In a realization relationship, one entity (normally an interface) defines a set of functionality as a method and other entity (normally a class) “realizes” uses by implementing the functionality defined in an interface.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s