Find relationships in uml class diagram
-
Hi I m trying to find relationship between classes in my program , I am not sure enough that i am right, do you have any ideas what relationships should be between the classes, thanks.
-
Hi
That was a new type of Question :)Do you mean UML Association ?
or what relationships are we talking about ?Like when to use Association versus Aggregation ?
-
Hi
That was a new type of Question :)Do you mean UML Association ?
or what relationships are we talking about ?Like when to use Association versus Aggregation ?
@mrjj All relationships that i made as Composition i tend to think could be association also so I have asked to know your opinion
-
@mrjj All relationships that i made as Composition i tend to think could be association also so I have asked to know your opinion
@mark_ua_1999
Well Association is the most used but it depends on how they exists and how they are really connected.
if we have A and B
then if A just uses B , its Association
if B is part of A it would be aggregation/composition.
If B is a type of A, inheritance might be usedhttps://www.visual-paradigm.com/guide/uml-unified-modeling-language/uml-aggregation-vs-composition/
So for Train and an Passager
A train transports passagers. Both the train and the passenger could exists without the other so
that is more of an Association than aggregation.Also for trainstops
A train is not really made up of train_stops so its not a aggregation as such. -
@mark_ua_1999
Well Association is the most used but it depends on how they exists and how they are really connected.
if we have A and B
then if A just uses B , its Association
if B is part of A it would be aggregation/composition.
If B is a type of A, inheritance might be usedhttps://www.visual-paradigm.com/guide/uml-unified-modeling-language/uml-aggregation-vs-composition/
So for Train and an Passager
A train transports passagers. Both the train and the passenger could exists without the other so
that is more of an Association than aggregation.Also for trainstops
A train is not really made up of train_stops so its not a aggregation as such.@mrjj ok and what about available_routes and arrival_city and passenger_train and available routes
(such the question confuse me about uml class diagrams when I use vector of some others items in any class should I think like in real (if the items could not exist without their container it is composition
but if could this is association ) (but when container class will be deleted programmly this items also will be deleted although it could be association) ) -
@mrjj ok and what about available_routes and arrival_city and passenger_train and available routes
(such the question confuse me about uml class diagrams when I use vector of some others items in any class should I think like in real (if the items could not exist without their container it is composition
but if could this is association ) (but when container class will be deleted programmly this items also will be deleted although it could be association) )@mark_ua_1999
Well most of the time UML diagrams tries to describe/model the reality and not the implementation.
So even you use a vector and its then seems sort of aggregated into the owning class, the diagram should show
the type of association from the real life.
You then choose to implement it with a vector but that an implementation detail.The association typed used tells how strong the association is but the programmer might implemented
in different ways depending on the need of the program.Example:
We have a room class and a house class.
We model the it as the house have 1 or more rooms and a room can be in exactly one house.
as a Composition. As in the real world room does not exists without a house.
But this is Sims6 and in the program we actually have a list of reusable rooms we can assign to houses
so in the programs the house just have a list of rooms that points to a list with available rooms.
So here the implementation, its actually implemented as a association/aggregation.So what to use depends on what type of Diagram you are trying to make.
Does it describe the real life world or does it describe implementation details ? -
@mark_ua_1999
Well most of the time UML diagrams tries to describe/model the reality and not the implementation.
So even you use a vector and its then seems sort of aggregated into the owning class, the diagram should show
the type of association from the real life.
You then choose to implement it with a vector but that an implementation detail.The association typed used tells how strong the association is but the programmer might implemented
in different ways depending on the need of the program.Example:
We have a room class and a house class.
We model the it as the house have 1 or more rooms and a room can be in exactly one house.
as a Composition. As in the real world room does not exists without a house.
But this is Sims6 and in the program we actually have a list of reusable rooms we can assign to houses
so in the programs the house just have a list of rooms that points to a list with available rooms.
So here the implementation, its actually implemented as a association/aggregation.So what to use depends on what type of Diagram you are trying to make.
Does it describe the real life world or does it describe implementation details ?@mrjj So I tend to think that arrival_city and available_rotes has relationship composition although arrival_city could exist like city without depart city(from) in available_routes, but route itself could not exist without arrival city is it good idea?
And should i think so(composition) about available_routes in passenger_train? -
@mrjj So I tend to think that arrival_city and available_rotes has relationship composition although arrival_city could exist like city without depart city(from) in available_routes, but route itself could not exist without arrival city is it good idea?
And should i think so(composition) about available_routes in passenger_train?@mark_ua_1999
Well a route is made of arrival_cities and its a strong association since it would not really be a route if
it has no cites and hence aggregation/composition seems very valid.For available_routes and passenger_train , one could say that a train can have/use/run on 1 or more
of the available_routes and hence the association is not that strong so its more of an Association
than an aggregation.Note that a composition is a strong version of an aggregation and hints that the composited
object is very tied to the owning class and would not exits on its own. -
@mark_ua_1999
Well a route is made of arrival_cities and its a strong association since it would not really be a route if
it has no cites and hence aggregation/composition seems very valid.For available_routes and passenger_train , one could say that a train can have/use/run on 1 or more
of the available_routes and hence the association is not that strong so its more of an Association
than an aggregation.Note that a composition is a strong version of an aggregation and hints that the composited
object is very tied to the owning class and would not exits on its own.@mrjj thaks if we destroyed the train the route become also invalid (i mean about all routes saved in vector that belong to one big route f.e Kyiv-Lviv-Warsaw-Berlin-Paris, Kyiv-Lviv-Warsaw-Berlin, Kyiv-Lviv-Warsaw, Kyiv-Lviv, Lviv-Warsaw-Berlin-Paris, Lviv-Warsaw-Berlin, Lviv-Warsaw, Warsaw-Berlin-Paris, Warsaw-Berlin, Berlin-Paris) My program doesnt create one route 2 times so could i think
that my route depend on whether the train exist so it is possible to be composition? -
@mrjj thaks if we destroyed the train the route become also invalid (i mean about all routes saved in vector that belong to one big route f.e Kyiv-Lviv-Warsaw-Berlin-Paris, Kyiv-Lviv-Warsaw-Berlin, Kyiv-Lviv-Warsaw, Kyiv-Lviv, Lviv-Warsaw-Berlin-Paris, Lviv-Warsaw-Berlin, Lviv-Warsaw, Warsaw-Berlin-Paris, Warsaw-Berlin, Berlin-Paris) My program doesnt create one route 2 times so could i think
that my route depend on whether the train exist so it is possible to be composition?@mark_ua_1999
Yes then the actual implementation will use composition and its up to show what you want to show on the diagram.
A diagram can be a Design specification or Implementation specification and it sounds like you want to show
implementation details. -
This post is deleted!