By studying associations in UML (aggregation and composition) I realized that the difference between them would be only the existence or not of the parts without the whole.
- Aggregation = > Parts exist without the whole
- Composition = > Parts do not exist without the whole
Both deal with rules in the Part object, but I did not find anything that denoted rules in the whole object, eg
A request (Todo) consists of items (Part), there are no items without the whole (composition), the question is that a request also does not exist without items, how to represent this rule in the UML? that is, where I say that the whole object also does not exist without the Part object?
It’s an interesting question. This relates to the Use Case – Customer – > Make Request. Describing the main functionalities of the system and the interaction of these functionalities with the users of the same system. This artifact is commonly derived from the requirements specification, which in turn is not part of the UML.
However, we can express it using the UML standards for use-case documentation.
Some books tell us that the whole does not exist (or does not make sense) without the parts.
Like aggregation, you must model a composition when the purpose of your model is to describe the structure of a relationship . A composition explicitly shows the whole / part structural relationship. So it’s implied that: “the whole object also does not exist without the part object”.
- A variation of the aggregation type
- Represents a stronger link
between whole-object and part-object
- Part objects must belong to the
- The whole does not exist (or does not make sense)
without the parties
- Or, the parts do not exist without the whole