UML关联

发布于 2024-10-13 02:13:46 字数 420 浏览 3 评论 0原文

我正在尝试阅读用于记录设计模式的 UML 类图。我了解聚合和组合 - 聚合使用空心菱​​形,组合使用实心菱形。

我在某处读到,虚线意味着实例化 - 即,如果一个类实例化另一个类,那么您使用从实例化器到实例化的虚线。首先,组合不会像我认为组合暗示所有权一样使用这个吗?

其次,我看到类之间绘制的线不是聚合或组合的 - 即根本没有diamnad。这是他们记录观察者模式的示例:

http://www.dofactory.com/Patterns/ PatternObserver.aspx

它们显示从主体到观察者的一条线,没有任何菱形。这到底是怎么回事?

谢谢

I'm trying to read UML Class diagrams used to document design patterns. I understand aggregation and composition - and aggregation uses the open diamond and composition uses the filled diamond.

I've read somewhere that a dotted line implies instantiation - i.e. if one class instantiates another then you use a dotted line from the instantiator to the instantiated. First, wouldn't composition use this as well as I thought composition implied ownership?

Second, I've seen lines drawn between classes which are not aggregate or composition - i.e. there's no diamnad at all. Here's an example where they are documenting the observer pattern:

http://www.dofactory.com/Patterns/PatternObserver.aspx

they show a line from subject to observer without any diamond. What's all this about?

thanks

Ray

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

居里长安 2024-10-20 02:13:46

UML 关联用于传达两个或多个分类器(例如类)之间的关系。组合和聚合是特殊的关联形式。

关联通常在类图中使用,以指示一个类的实例可以引用另一类的实例。例如,在您链接的图中,ConcreteObserver 和 ConcreteSubject 之间的关联意味着 ConcreteObserver 实例可以引用 ConcreteSubject 实例(请注意关联的方向性)。

A UML association is used to convey a relationship between two or more classifiers (e.g. classes). Compositions and aggregations are specialized forms of association.

Associations are often used in class diagrams to indicate that instances of one class can have references to instances of another class. For example, in the diagram to which you link, the association between ConcreteObserver and ConcreteSubject implies that a ConcreteObserver instance can have a reference to a ConcreteSubject instance (note the directionality of the association).

撩动你心 2024-10-20 02:13:46

虚线表示依赖性。有许多不同类型的依赖关系,其中之一是实例化。如前所述,关联是描述具有另一个类的属性的类之间关系的一种方式。当谈到类图中的类之间的关系时,最好从最具体的开始,逐渐走向更一般的关系。所以从组合、聚合、关联和依赖开始。

Dotted line implies dependency. There are many different types of dependency, one of them being instantiation. As said before, associations are a way to describe relationship between a classs having a property of another class. When it comes to relationships between classes in classs diagram, it is good to start from most concrete and go to more general. So start with composition, aggregation, association and dependency.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文