How should I denote static classes in UML?

非 Y 不嫁゛ 提交于 2019-11-29 18:17:37

问题


So I did some research about how to denote static methods and classes in UML. I found on these two pages that static methods should be denoted by underlining them, but what is the correct way to display a class as being static?


回答1:


Marking a class as static is a very low level information, which we don't put in UML diagrams usually. UML 1.0 as well as 2.0 gives some flexibility to designer/developer to modify the convention if it suits to your audience/team.

You can put a note to that class, or use something like <<static>>( as used for interface).




回答2:


I would just use a stereotype <<static>>




回答3:


IMO static classes (like in C#) should not even be used in OO Design. A static class cannot be instantiated and thus is actually not a class regarding UML semantics.

You could mark the class as "leaf" (no subclasses) and add a constraint which does not allow non-static members. This would resemble the meaning of the C# static keyword.




回答4:


Static classes are usually denoted by underlining the class name. Its a convention to underline static features, so it makes sense that underlining the class name would denote a static class.



来源:https://stackoverflow.com/questions/13679791/how-should-i-denote-static-classes-in-uml

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!