A
A
Andrew2020-01-21 16:47:25
Software design
Andrew, 2020-01-21 16:47:25

Can one object belong to two composites?

I am compiling a class diagram and faced the question: can one object belong to several composites (aggregates).
For example, there are classes Comment, Article, Movie, Like.
5e26ffa16d1ca839628210.png
It can be seen from laughter that Like is part of three objects, and according to the Like logic, each object has its own.
Is the diagram correct? Or should it be replaced with a regular association?
How to display this relationship on the diagram?
Tell me or share a source where to read.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Rozhkov, 2020-01-21
@Coqueros

can one object belong to several composites (aggregates)
Formally, the UML does not forbid this, so you can.
You can see from the laugh that Like is part of three objects
- The part-whole relation is an aggregation. You have a composition: an instance of the like class can ONLY exist inside instances of these three classes. Destroyed comment - Destroyed and like
Or should it be replaced with a regular association?
Well, here it is important to understand the business context of the subject area and the use cases for likes and what you want to get from such a diagram.
Martin Fowler.UML. Fundamentals, 3rd Edition
The UML Language. User Manual. Grady Booch, James Rumbaugh

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question