java UML 图 - 如何显示 FINAL
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/47588511/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
UML diagram - how to show FINAL
提问by Istiak Khan
How would I indicate a
我将如何表示
"private static final int DAMAGE = 3;" in a uml diagram?
“私有静态最终 int DAMAGE = 3;” 在 uml 图中?
Would it show up as : - DAMAGE : 3 : int
它会显示为 : - DAMAGE : 3 : int
Any help would be appreciated.
任何帮助,将不胜感激。
采纳答案by deHaar
For an UML representation of a Java project, it should be sufficient to write underlined caps, like…
对于 Java 项目的 UML 表示,编写带下划线的大写字母应该就足够了,例如……
Notethat this representation uses a Java convention (constants written in capitals) to highlight it as final
instead of a UML annotation, which would be kind of more straight-forward UML, but is too long for my purposes.
请注意,此表示使用 Java 约定(以大写字母书写的常量)来突出显示它final
而不是 UML 注释,这将是一种更直接的 UML,但对于我的目的来说太长了。
回答by qwerty_so
You show it like this.
你这样展示。
Private
is symbolized by a minus. The static
attribute is shown by an underline. The initial value is shown by = <value>
. Since I learned that final
denotes a constant, you will apply the isConst
property which is shown as {readOnly}
.
Private
用减号表示。该static
属性由下划线显示。初始值用 表示= <value>
。由于我了解到final
表示一个常数,因此您将应用isConst
显示为的属性{readOnly}
。
See also p. 111 of the UML spec:
另见第 UML 规范的第 111 条:
<property> ::= [<visibility>] [‘/'] <name> [‘:' <prop-type>] [‘[‘ <multiplicity-range> ‘]'] [‘=' <default>] [‘{‘ <prop-modifier > [‘,' <prop-modifier >]* '}']
[ details omitted ]
<property> ::= [<visibility>] [‘/'] <name> [‘:' <prop-type>] [‘[‘ <multiplicity-range> ‘]'] [‘=' <default>] [‘{‘ <prop-modifier > [‘,' <prop-modifier >]* '}']
[细节省略]
No longer relevant in this context, but leaving it anyway:
在这种情况下不再相关,但无论如何都要离开它:
Re. @granier's comment about tagged values: Indeed UML 2.5 does no longer really use tagged values. There are only 3 mentions of it:
回覆。@granier 关于标记值的评论:实际上 UML 2.5 不再真正使用标记值。只有3处提到它:
mainly p. 205
Just like a Class, a Stereotype may have Properties, which have traditionally been referred to as Tag Definitions. When a Stereotype is applied to a model element, the values of the Properties have traditionally been referred to as tagged values.
主要是p。205
就像一个类,一个原型可能有属性,传统上被称为标签定义。当 Stereotype 应用于模型元素时,属性的值传统上被称为标记值。
So tagged valueis an "ancient" term and should further be called stereotype property.
所以标记值是一个“古老”的术语,应该进一步称为原型属性。