UML中的语义关系 [英] Semantic relationship in UML

查看:135
本文介绍了UML中的语义关系的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在UML中找到了一个关联定义,如下所示. 协会"在UML中定义为之间的一种关系 类,表示两个或多个以下类之间的语义关系 涉及其实例之间的连接(链接).

I found a definition for association in UML as below. An "association" in UML is defined as a kind of relationship between classes,which represents the semantic relationship between two or more classes that involves connections (links) among their instances .

我不清楚什么是语义关系.有人可以通过示例与非语义关系进行比较来解释它吗?

I am not clear what is semantic relationship. Can anyone explain it with example with comparing it with non semantic relationship?

推荐答案

根据UML规范,关联表示语义关系.

An association represents a semantic relationship according to the UML specs.

语义关系 是一个意义本身具有意义的关系.

A semantic relationship is a relationship about meanings that has itself a meaning.

该术语是借用到语言学和相关学科的,在这些学科中单词被映射为其含义,并根据此映射分析单词的关系.但是在开始抽象之前,一张图片价值1000字:

This term is borrowed to linguistics and related disciplines, where words are mapped to their meaning, and the relation of words is analysed in view of this mapping. But before getting to abstract, a picture is worth 1000 words:

因此,使用UML(建模语言)的这一元素而不是英语单词(自然语言):如果您具有类CarDriver,则可以将语义关系建模为两者之间的关联课.

So, applying this elements of UML (modelling language) instead of English words (natural language): if you'd have the classes Car and Driver, you CAN model the semantic relationship as an association between the two classes.

在某些Driver与它们的Spouse之间也可能存在语义关系,这意味着您也可以对这种关联进行建模.但这不是强制性的.幸运的是!因为否则,通过传递性,您很快就会在模型中拥有世界其他地方;-)

There can also be a semantic relationship between some Driver and their Spouse meaning that you CAN also model such an association. But this is not mandatory. Fortunately! because otherwise by transitivity you'd quickly have the rest of the world in your model ;-)

如果与您的应用程序域相关,那么您当然也可以显示这种关联(例如,您在一家保险公司工作,其价格取决于拥有驾照的家庭成员的数量).您甚至可能想通过使用

If it is relevant for your application domain you may of course show this association as well (e.g. you're working in an insurance company where the prices depends on how many family members have a driving license). And you may even want to make explicit the indirect relation of Spouse and Car, by using the notation for derived association with the leading /.

并非所有关系都是语义性质的.例如,您可以具有依赖性,它可以表示技术上的关系.例如,如果使用出厂设计模式,则DriverFactory«create» Driver.这本身没有任何意义:这只是表示形式领域中的一种关系.另一方面,您可能想给它一个含义,让工厂跟踪所创建的驱动程序,即使这仅对您的抽象设计有意义,而不对现实世界有意义.如果有帮助,您可以将其设为关联.

Not all relationships are of semantic nature. You can for example have dependencies, which can express a technical relationship. For example, if you use the factory design pattern, a DriverFactory will «create» the Driver. This has on its own no meaning: It's just a relationship in the domain of the representations. On the other side, you may want to give it a meaning and let the factory keep trace of the drivers created, even if it makes only sense in the meaning of your abstract design and not in the real world. You then CAN make it an association if it helps.

最终,当您想查看关联时,您有一定的解释空间.如果您希望模型继续提供帮助,请稀疏使用.

Ultimately, you have a some room for interpretation when you want to see an association and when not. Use it sparsely however, if you want your model to remain helpful.

为了便于记录,我只能绘制矩形,对此我深表感激. 18f 就包容性沟通提出建议.

For the records, I can only draw rectangles, and I'm grateful to this public domain contributor for the nice car and driver and to 18f for its advice on inclusive communication.

这篇关于UML中的语义关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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