Saturday, 7 September 2019

Aggregation in java


Aggregation
Aggregation has a relationship between two classes. In this relationship the object of one class is a member of the other class. Aggregation always insists for a direction.
Class A contains Class B , Or Class A has instance of Class B.

Example:
  • Manager has N Employees for a project. 
  • Team has Players.
·         An aggregation is used whenlife of object is independent of container object But still container object owns the aggregated object.
·         Eg. Team has players, If team dissolve, Player will still exists.

Aggregation UML Notation:
Aggregations are represented by the line with diamond.


Life or existance of the aggregated objects are independent of each other, But one object is playing the role of Owner of the other object.

No comments:

Post a Comment

Note: only a member of this blog may post a comment.