Aggregation in OOP with Visual Basic .NET

Last Updated: September 4, 2017

Aggregation is a collection or formation number of things to cluster. In Object Oriented Programming , Aggregation is whole part relationship (You should have the association between classes)

Aggregation is a subset of the association

In the following example Class B is part of Class A and also this has the association


We can name the Class A as Whole Class B as Part

When you draw the class diagram the hollow diamond is next to the whole

Now lets look at some real world representation

You can think of the Car and Wheel relationship. Wheel is a part of the Car

aggregation model

In this UML diagram you can see that there is association between Car and Wheel. You can say, Car has wheels . So you have “has” relationship. It means you have the Association

Wheel is part of the Car.  Now car is Whole wheel is Part . You can draw hollow diamond next to the Car. You can see now Aggregation

Now I will code this UML diagram in VB.NET so that you can understand association comprehensively

Car Class in VB.NET

Public Class Car
    Private m_wheels() As Wheel

    Public Sub SomeMethod()

    End Sub

End Class

Wheel Class in VB.NET

Public Class Wheel
    Private m_size As Integer
    Public Sub SomeMethod()

    End Sub
End Class