描述关系的 UML 表示法
UML Notation for depicting relationship
谁能给我解释一下下面所示的 UML class 图表中突出显示的元素的含义:
- 加号
- 大括号内的文字
上图取自 http://www.omg.org/spec/UML/
的 UML 规范
进一步阅读我发现
大括号称为"adornments",在本例中已放在关系上。在这种情况下,它们已用于对作为关系一部分的元素施加约束。
仍然没有关于 + 符号的线索。
装饰是添加到连接器的所有内容,即文本标签。大括号是约束。这些可以是纯文本或 OCL。 subsets
是 UML 中的关键字。 UML 规范的第 17 页说
Association Ends: each specified by its name, type, and multiplicity, any additional properties such as {union}, and a link to its opposite end. If the association end subsets or redefines others, this is shown in the additional properties as {subsets } or {redefines }, where is a link to the applicable end. This is followed by a textual description of the purpose and meaning of the association end. If an association end is derived, the name will be preceded by a forward slash. If the association end is a composition, this is indicated by a small black diamond adjacent to the name of the end.
加号表示属性(角色名称 ownedTemplateSignature
是)具有 public 可见性。规格的第 60 页:
- public
A Named Element with public visibility is visible to all elements that can access the contents of the Namespace that owns it.
- private
A NamedElement with private visibility is only visible inside the Namespace that owns it.
- protected
A NamedElement with protected visibility is visible to Elements that have a generalization relationship to the Namespace that owns it.
- package
A NamedElement with package visibility is visible to all Elements within the nearest enclosing Package (given that other owning Elements have proper visibility). Outside the nearest enclosing Package, a NamedElement marked as having package visibility is not visible. Only NamedElements that are not owned by Packages can be marked as having package visibility.
在第111:
<visibility> is the visibility of the Property. (See VisibilityKind - sub clause 7.4.)
<visibility> ::= ‘+’ | ‘-‘ | ‘#’ | ‘~’
(按照上面列表的顺序,例如'+'是public)
并且按照@granier 的建议进行扩展,关联末尾的小点(已在 2.1.1 中引入)具有以下含义:(第 200 页)
Ownership of Association ends by an associated Classifier may be indicated graphically by a small filled circle, which for brevity we will term a dot. The dot is to be drawn integral to the graphic path of the line, at the point where it meets the Classifier, inserted between the end of the line and the side of the node representing the Classifier. The diameter of the dot shall not exceed half the height of the aggregation diamond, and shall be larger than the width of the line. This avoids visual confusion with the filled diamond notation while ensuring that it can be distinguished from the line. The dot shows that the model includes a Property of the type represented by the Classifier touched by the dot. This Property is owned by the Classifier at the other end. In such a case it is normal to suppress the Property from the attributes compartment of the owning Classifier.
实际上整个页面都在谈论所有权和导航性。但基本上点意味着另一端的 class 拥有关系,这意味着它可以导航到带点的 class。两边的点表示两个 class 都认识对方。
谁能给我解释一下下面所示的 UML class 图表中突出显示的元素的含义:
- 加号
- 大括号内的文字
上图取自 http://www.omg.org/spec/UML/
的 UML 规范进一步阅读我发现
大括号称为"adornments",在本例中已放在关系上。在这种情况下,它们已用于对作为关系一部分的元素施加约束。
仍然没有关于 + 符号的线索。
装饰是添加到连接器的所有内容,即文本标签。大括号是约束。这些可以是纯文本或 OCL。 subsets
是 UML 中的关键字。 UML 规范的第 17 页说
Association Ends: each specified by its name, type, and multiplicity, any additional properties such as {union}, and a link to its opposite end. If the association end subsets or redefines others, this is shown in the additional properties as {subsets } or {redefines }, where is a link to the applicable end. This is followed by a textual description of the purpose and meaning of the association end. If an association end is derived, the name will be preceded by a forward slash. If the association end is a composition, this is indicated by a small black diamond adjacent to the name of the end.
加号表示属性(角色名称 ownedTemplateSignature
是)具有 public 可见性。规格的第 60 页:
- public A Named Element with public visibility is visible to all elements that can access the contents of the Namespace that owns it.
- private A NamedElement with private visibility is only visible inside the Namespace that owns it.
- protected A NamedElement with protected visibility is visible to Elements that have a generalization relationship to the Namespace that owns it.
- package A NamedElement with package visibility is visible to all Elements within the nearest enclosing Package (given that other owning Elements have proper visibility). Outside the nearest enclosing Package, a NamedElement marked as having package visibility is not visible. Only NamedElements that are not owned by Packages can be marked as having package visibility.
在第111:
<visibility> is the visibility of the Property. (See VisibilityKind - sub clause 7.4.) <visibility> ::= ‘+’ | ‘-‘ | ‘#’ | ‘~’
(按照上面列表的顺序,例如'+'是public)
并且按照@granier 的建议进行扩展,关联末尾的小点(已在 2.1.1 中引入)具有以下含义:(第 200 页)
Ownership of Association ends by an associated Classifier may be indicated graphically by a small filled circle, which for brevity we will term a dot. The dot is to be drawn integral to the graphic path of the line, at the point where it meets the Classifier, inserted between the end of the line and the side of the node representing the Classifier. The diameter of the dot shall not exceed half the height of the aggregation diamond, and shall be larger than the width of the line. This avoids visual confusion with the filled diamond notation while ensuring that it can be distinguished from the line. The dot shows that the model includes a Property of the type represented by the Classifier touched by the dot. This Property is owned by the Classifier at the other end. In such a case it is normal to suppress the Property from the attributes compartment of the owning Classifier.
实际上整个页面都在谈论所有权和导航性。但基本上点意味着另一端的 class 拥有关系,这意味着它可以导航到带点的 class。两边的点表示两个 class 都认识对方。