Ad Code

Aggregation is strong or week ?


Aggregation is a weak relationship between objects because in case of aggregation, the relating objects have their own life and each object can maintain its state independently " while in the lectures teacher said that Aggregation is strong relationship and one object is dependent on other object.


Now Aggregation is strong or week ?



You should not get confused with normal aggregation and another special form of aggregation that is strong aggregation which is also called Composition. Normally, in case of normal Aggregation, an object of one class is contained in an object of some other class. If container object is deleted then it does not mean that the contained object will also delete. The life cycle of contained class object does not depend on the life cycle of container class therefore this type of aggregation is called weak relation. Let me again explain it with an example.

A cricket team contains players. Now if some player is dropped out of the team then still he will remain a player. So there is a weak relation between team and player.

Now, let us take the example to explain stronger aggregation (Composition). Composition means that one object is made up of many other objects. In case of composition, the contained object is destroyed as soon as the container object gets destroyed.

For example, a book is made up of many chapters or lessons. But if we delete the book then chapters will also be deleted.
Reactions

Post a Comment

0 Comments