Java Programming Tutorial - 32 - Composition

preview_player
Показать описание
Brief demonstration on composition in Java, Object Oriented Programming
Рекомендации по теме
Комментарии
Автор

From what I learned from other tutorials an aggregation is a “has-a” relationship. While composition is “part-of” relationship. Sorry, but unless I’m seeing this wrong, this is an example of an aggregation relationship and not composition. I’m aggregation, the objects can exists ehjthkut each other. Such as the let and person can exist in their own. But in composition, the objects exist together and if one is deleted the other is also useless. Such as a car and an engine. An engine is “part of” a car. So when you constructs both objects the need to exist together and reply on references to each other.

johnson
Автор

Great video, thanks for this explanation. But I think this explain more the polymorphisme than Composition.

seydinamouhamedgueye
Автор

“Has-a” is for aggregation, not composition!

ah.
Автор

That helped me learn Composition a lot quicker! Thanks mate!

tonkata
Автор

Appreciate it friend, this helped me big time.

soulgure
Автор

how is getName() retrieving the name of the Pet, knowing that only the Person class has the name property

egbe-iyonmichael
Автор

Also upload a video for aggregation which is loose coupling... Thank you!

abhiny
Автор

It’s example of aggregation not composition, in composition container class cannot exist without contained . Pls stop sharing miss info

aryamangupta