关联类与属性 [英] Association Class vs. Attribute

查看:181
本文介绍了关联类与属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

让我们假设我有2个教学班,关联关系。

Let's assume I have 2 classes with association relation.

什么是加入之间的区别的属性以类之一,并添加协会类与属性?

What is the difference between adding attributes to one of the classes and adding an Association Class with attributes?

据我所知,关联类描述关联关系,但我不能改用简单的类属性?结果
什么是协会类的附加价值?

I understand that association class describes the association relation, but cannot I use simple class attributes instead?
What are the added values of Association Class?

推荐答案

协会和属性实际上是同一事物的不同效果。所不同的是一个比较深奥的性质。的关联是视觉上更比一个属性暴露出来。所以,你会使用属性,如果有一个更重要的地方,而不是更多的系统在广泛的关联情况。

Association and attributes are actually different renderings of the same thing. The difference is more a bit of esoteric nature. An association is visually more exposed than an attribute. So you would use the attribute if it has a more local importance rather than a more system wide in case of an association.

你不应该做的就是同时使用。当使用关联,你需要它命名然后用角色与联想一起,不重复的属性。

What you should not do is to use both. When using an association and you need to name it then use a role along with the association and do not repeat it as attribute.

关联类(AC)实际上是一类和关联的组合(UML它从两个继承)。这样两个类之间的关系纯正可以有方法和属性本身。如果要涉及两个类与M-N关系的关联类使用。例如。 学生考试之间的交流说明学生已经在考试中取得的成果。所以,你有一个1级-M AC N-1级的关系,而不是数组中任一对立的阶级属性有这个信息。

An association class (AC) is actually a combination of a class and an association (in UML it inherits from both). This way the pure relation between two classes can have methods and attributes itself. An association class is used if you want to relate two classes with M-N relation. E.g. the AC between Student and Exam describes the results a student has achieved in exams. So you have a Class 1-M AC N-1 Class relation rather than having this information as array attributes inside either of the opposing classes.

作为一个方面说明(因为你标记它EA):EA在从类的属性喂角色提供了一个下拉。你不应该利用这一点。这是一些遗产和/或定义的misinter pretation。至于说:它没有错,但也不好作风

As a side note (since you tagged it EA): EA offers a drop down in the roles which is fed from attributes of the class. You should not make use of that. This is some heritage and/or a misinterpretation of the definition. As said: its not wrong, but also not good style.

这篇关于关联类与属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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