如何声明 UML 类图扫描器扫描声明?

huangapple go评论65阅读模式
英文:

How to declare UML class diagram scanner scan declaration?

问题

你好,在 UML 类图中声明 Scanner 的适当方式是这样的:
+scan: Scanner 或者 +scan: Scanner(System.in),或者其他方式。此外,还有其他需要添加的内容吗?哦,是的,我正在表示 Java。

谢谢

英文:

Hi what is the proper way to declare a scanner on a uml class diagram, like this
+scan: Scanner or +scan: Scanner(System.in) or something else. Also anything else I should add? Oh yeah I'm representing java.

Thanks

答案1

得分: 4

如果我理解正确,scan 是一个类的属性,Scanner(System.in) 是你初始化它的方式(默认值)

如在 formal/2017-12-05 第 9.5.4 节第 113 页所指定的那样:

[<visibility>] [‘/’] <name> [‘:’ <prop-type>] [‘[‘ <multiplicity-range> ‘]’]
    [‘=’ <default>] [‘{‘ <prop-modifier > [‘,’ <prop-modifier >]* ’}’]

首先要注意的是可见性,‘+’ 表示 public,你确定你要将属性设置为 public 吗?这是危险的,因为这意味着它可以从任何其他类进行修改。

除此之外,如果你只想指示其可见性和类型:+scan : Scanner

如果你还想指示其默认值:+scan : Scanner = Scanner(System.in)

因此,+scan: Scanner(System.in) 是错误的。

英文:

If I well understand scan is an attribute of a class and Scanner(System.in) the way you initialize it (default value)

As specified in the formal/2017-12-05 §9.5.4 from page 113 the notation is :

[<visibility>] [‘/’] <name> [‘:’ <prop-type>] [‘[‘ <multiplicity-range> ‘]’]
    [‘=’ <default>] [‘{‘ <prop-modifier > [‘,’ <prop-modifier >]* ’}’]

A first remark concern the visibility, '+' means public, are you sure you want your attribute public ? This is dangerous because that means it can be modified from any other class.

Out of that if you want to only indicate its visibility and type : +scan : Scanner

If you want to also indicate its default value : +scan : Scanner = Scanner(System.in)

So +scan: Scanner(System.in) is wrong

huangapple
  • 本文由 发表于 2020年10月10日 12:36:21
  • 转载请务必保留本文链接:https://go.coder-hub.com/64290015.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定