Distinguishing connecting representation.
| Extension | <|-- |
|
| Composition | *-- |
![]() |
| Aggregation | o-- |
![]() |
Normaly developers used to 3 types of line such as Extension, Composition and Aggregation for representing connectivity of classes.
For detail, let me explain each ones.
Extension is most simple. If you extend class using some interface or some abstract class then use Extension line that directed to upper interface or class.
Composition and Aggregation is little bit similar but I can explain differencies few point. Composition is used when class was directly used inside of directed class, that means that class has the property of other class. Aggregation is used when class was used to arguments of some functions or constructors. Aggregation doesn’t used for declaring inside of targeted class.
Let me show with examples.
Extension
class A2 extends A {
}
A2 -|> A
Composition
class A {
B b = new B();
B get(){
return this.b;
}
}
B -* A
Aggregation
class A {
void use(B b){
b.use();
}
}
B -o A
Three types of connectivity can be explanin most of case the class structure, but if we need to some extended explaination, use note representation. That will be more clear then use other type of connection representation.


Leave a comment