Understanding differences – Association, Aggregation & Composition – OOAD – C Sharp

This Qikkwit will explain concepts of Association, Aggregation and Composition in object oriented design with help of UML,  Real life and C Sharp example.

object-oriented-design-principals

object-oriented-design-principals

1. Association: Its nothing but relation between two entities. E.g. Car with wheel or Father and Son. Both are dependent on each other but both can live and exist without each other. In practice we avoid strong dependency by use of Interfaces and Dependency Injection.

object-oriented-design-association

object-oriented-design-association

object-oriented-design-association-csharp

object-oriented-design-association-csharp

object-oriented-design-association-uml

object-oriented-design-association-uml

2. Aggregation: Its nothing but relation between two entities but as Parent and Child. Child is always contained in parent but still can live without parent. E.g. A family lives in home but it can go out and stay in hotel or resort. In practice we avoid strong dependency by use of Interfaces and Dependency Injection.

happy family at home over a white background

happy family at home over a white background

object-oriented-design-aggregation-csharp

object-oriented-design-aggregation-csharp

object-oriented-design-aggregation-uml

object-oriented-design-aggregation-uml

3. Composition :  Its nothing but relation between two entities but as Parent and Child but a child can not live without parent. E.g. a brain can not function outside head or a engine can not function outside car. In practice we avoid strong dependency by use of Interfaces and Dependency Injection.

object-oriented-design-composition

object-oriented-design-composition

object-oriented-design-composition-uml

object-oriented-design-composition-uml

object-oriented-design-composition-csharp

object-oriented-design-composition-csharp

Leave a Reply

Your email address will not be published. Required fields are marked *