Is there a convention for showing overridden methods in UML static class diagrams?

a 夏天 提交于 2020-01-01 04:11:05

问题


If class Human inherits some methods from superclass Mammal unchanged (such as laysEggs: () -> false) and overrides other methods (such as postsToStackOverflow : () -> true), is there any difference between how the different methods are indicated in portion of the UML static class diagram for Human? For example, are only the overridden methods shown in the box for Human, or are both shown, with some annotation for the overridden methods?


回答1:


Now there is. Some anonymous got me to dig into the 2.5.1. specs. On p. 102 it says

Members that are inherited by a Classifier may be shown on a diagram of that Classifier by prepending a caret ’^’ symbol to the textual representation that would be shown if the member were not inherited. Thus the notation for an inherited Property is defined like this:

<inherited-property> ::= ’^’ <property>

The specs itself does not (yet) make much use of the caret notation except for figure 9.11 on p. 115 and figure 10.9 on p. 173.


In the specs for 2.5 and before the answer was: No, there isn't. You can only tell that a method is overridden by inspecting the methods of the class from which is inherited.




回答2:


Though not specified in the UML standard, following is a notation understood to indicate when one function overrides another:

+ toString() : String <<override>>



回答3:


I duplicate method declaration, if I want to show that inherited class will override it, in other case just omit declaration.



来源:https://stackoverflow.com/questions/28930476/is-there-a-convention-for-showing-overridden-methods-in-uml-static-class-diagram

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