关系(聚合、组合)是否取代了属性? [英] Does a relation (aggregation, composition) replace an attribute?

查看:22
本文介绍了关系(聚合、组合)是否取代了属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对 UML 建模还很陌生,所以请耐心等待.

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

假设我有一个带有属性 students 的类,它是一个 Student 实例的列表.我已经为同样在图中的 Student 类设置了聚合关系.这种关系是否替换容器类中的一个属性条目,例如#students : Student[],或者属性和关系可以共存?

Say I have a class with an attribute students that is a list of Student instances. I have set an aggregation relation to the Student class which is also in the diagram. Does this relation replace an attribute entry such as #students : Student[] in the container class, or can the attribute and relation co-exist?

提前感谢您的回答!

推荐答案

简答:属性和关系都可以存在吗?没有...

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:

但是如果您的类不是软件类并且您对域进行建模,您应该更加小心地将实体显示为属性或类.通常,如果实体是复杂类型,则显示为单独的类.但这不是规则:取决于上下文.

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.

这篇关于关系(聚合、组合)是否取代了属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆