0
3.3kviews
Explain association and aggregation with suitable example.

Mumbai University > Information Technology > Sem 3 > Object Oriented Programming Methodology

Marks: 4M

Year: Dec 2013

1 Answer
0
63views

Association:

  • When a classes are connected together conceptually, that connection is called an association.
  • When one class associated with another, each one usually plays a role within that association.
  • One can show each class’s role by writing it next to the class. Here is an example:
  • The association between a player and a team, we can call this association as “player plays for a team”. We can create the association by drawing a line between two classes and writing name over it.

enter image description here

  • There can be more than one association between the two classes. For example, if the team is professional, it’s an employer and the player is an employee. Then the diagram can be drawn as:

enter image description here

Aggregation:

  • Sometimes, a class consists of a number of component classes. This type of relation between class and its various components is called as aggregation.
  • The components and the class they constitute are in a part-whole association.
  • For example, a desktop computer system is an aggregation that consists of a CPU box, a keyboard, a mouse, a monitor, a CD-ROM drive, a hard drive, a RAM, a graphics card, a sound card and probably more items.
  • We can represent an aggregation as a hierarchy with the whole class as computer system and components below it.
  • A line joins a whole to a component, with an open diamond on a line near the whole.

enter image description here

Please log in to add an answer.