Does a relation (aggregation, composition) replace an attribute?

后端 未结 3 499
野趣味
野趣味 2020-12-30 15:41

I\'m pretty new at UML modelling so bear with me.

Say I have a class with an attribute students that is a list of Student instances. I have

相关标签:
3条回答
  • 2020-12-30 16:06

    Short answer: Can the attribute and relationship both exist? No...

    But if your classes are software classes you may have many choices for showing them:

    enter image description here

    But if your classes are not sofware classes and you model the domain you should be more carefully to show an entity as an attribute or class. Generally if the entity is complex type, it is shown as seperate class. But that is not a rule: depends on context.

    enter image description here

    0 讨论(0)
  • 2020-12-30 16:09

    You generally do not have attributes of a user-defined (or any complex) class. You certainly don't show an attribute AND an association for the same thing in UML. If I understand your situation, you're in need of an association (or aggregation/composition)... And play with the multiplicities to get it right.

    0 讨论(0)
  • 2020-12-30 16:22

    An attribute helps to identify the structure of the object. Aggregation gives a high level overview that the object will contain one (or more) of another type. Neither replaces, but instead shows the relationship between the object types.

    0 讨论(0)
提交回复
热议问题