Reputation: 9396
Just started with Star UML
to draw a class diagram
.
As with any application, MyBLL
(business layer) creates an instance of Model
after interacting with the DAO
(database layer).
More or less, the simplified (for clarity) class diagram looks like this:
It is obvious that the model class will no longer be used after BLL is done.
What should I use here? aggregation
or composition
while mapping MyBLL
to MyModel
.
I have used a composition
relationship from MyBLL
to MyDAO
. My logic is after the BLL
layer exists, MyDAO
will no longer exist because it is referenced in MyBLL
. Is this correct?
Note: This is for a WebAPI
project that I am creating using C#.
Upvotes: 1
Views: 665
Reputation: 8147
Aggregate means that the child CAN exist without the parent. So, Classroom
(parent) and Student
(child) is the most common example. Where you can have classrooms and students independently.
Composite means that the child CANNOT exist without the parent. So, House
(parent) and Room
(child) is the most common example. Where you cannot have a room without it being inside a house.
Without seeing exactly how you are coding this I am guessing that you will have this:
1) MyModel is probably a composite relationship because it is contained (with other models) within your MyBLL for its whole life. When MyBLL goes out of scope so too does MyModel.
2) MyDAO is probably an aggregate because it can exist without MyBLL as it is used by other components? I.e. It is probably created outside of your MyBLL by the host and injected into your BLL?
Both of these statements may not be true based on the actual way your have architected your system.
Upvotes: 5