Association

1,329 views 9 slides Dec 24, 2018
Slide 1
Slide 1 of 9
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9

About This Presentation

A ppt on Association


Slide Content

Association Association is a relationship between two objects. In other words, association defines the multiplicity between objects. You may be aware of one-to-one, one-to-many, many-to-one, many-to-many all these words define an association between objects. Aggregation is a special form of association. Composition is a special form of aggregation.

HAS – A RELATIONSHIP Association is a “has-a” type relationship. Association establish the relationship b/w two classes using through their objects. Association relationship can be one to one, One to many, many to one and many to many. For example suppose we have two classes then these two classes are said to be “has-a” relationship if both of these entities share each other’s object for some work and at the same time they can exists without each others dependency or both have their own life time.

REPRESNTING Association If two classes in a model need to communicate with each other, there must be link between them, and that can be represented by an association (connector). Association can be represented by a line between these classes with an arrow indicating the navigation direction. In case arrow is on the both sides, association has bidirectional association.

REAL LIFE EXAMPLE Student -Teacher. A Teacher can teach a class of students and at the same time a Student can attend multiple classes. Both objects can be created and destroyed independently . Relationship of a member to a club . A club have number of members and a single member can have membership of multiple clubs

TYPES Association can be one-to-one, one-to-many, many-to-one, many-to-many. In Object-Oriented programming, an Object communicates to other Object to use functionality and services provided by that object.  Composition  and  Aggregation  are the two forms of association.

AGGREGATION Aggregation is a special case of association. A directional association between objects. When an object ‘has-a’ another object, then you have got an aggregation between them. Direction between them specified which object contains the other object. Aggregation is also called a “Has-a” relationship.

COMPOSITION Composition is a special case of aggregation. In a more specific manner, a restricted aggregation is called composition. When an object contains the other object, if the contained object cannot exist without the existence of container object, then it is called composition . Example :   A class contains students. A student cannot exist without a class. There exists composition between class and students.

Association vs Aggregation vs Composition