7

I am trying to create UML diagram. For example I have a class A with method a() and class B that extends A and overrides method a(). Is there any standard to indicate overridden methods in UML?

Kate
  • 71
  • 1
  • 1
  • 2
  • In fact a UML operation can redefine another Operation. – Red Beard Apr 24 '20 at 07:26
  • 1
    I temporarily closed the question because I thought it's a duplicate of https://stackoverflow.com/questions/28930476/is-there-a-convention-for-showing-overridden-methods-in-uml-static-class-diagram/28932482 but this one is about operations. And no, UML has no native way to show that for operations. – qwerty_so Apr 24 '20 at 08:21

3 Answers3

9

No, there is no specific indicator for operations that override operations on a parent class.
If the signature matches it overrides the operation on the parent.

enter image description here

Geert Bellekens
  • 12,788
  • 2
  • 23
  • 50
4

As indicated in that answer https://stackoverflow.com/a/28932482/2458991 there is a specific indicator to indicate a member (for instance an operation) is inherited, but that indicator is not mandatory, the norm 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.

So, having :

enter image description here

B does not override oper

But having :

enter image description here

we cannot know except if we are sure the ^ is always used in the model as in previous diagram

[edit]

Notice the norm use two times the words member (and not properties) in that sentence, and Class inherits (indirectly) Classifier, so that applies for operations.

As noticed in an other answer the norm says also :

Inherited members may also be shown in a lighter color to help distinguish them from non-inherited **members*.

so again two times members rather than properties, and the fact they use also clearly reference the fact there is an other way which is the ^. So two consistent sentences indicating ^ applies to operations

[warning]

I used BoUML to make the diagrams and in the first you can see "^oper()" but I 'cheated' to do that naming the corresponding operation "^oper", there is no option to show a ^ in a diagram to indicate an operation or other member is inherited

bruno
  • 32,421
  • 7
  • 25
  • 37
  • I think the "may" in that sentence indicates that showing inherited members is optional. I believe that if you show them the caret symbol is mandatory. – Geert Bellekens Apr 24 '20 at 09:18
  • 1
    @GeertBellekens no, for me the 'ma'y concerns "*be shown on a diagram of that Classifier by prepending a caret ’^’ symbol to the textual representation*" and not only "*be shown on a diagram of that Classifier*". If I am not wrong I see elsewhere in the norm where the ^ is not used – bruno Apr 24 '20 at 09:20
  • 1
    I added some text about the UML ambiguity to my answer. Let's leave it that way and have a coffee ;-) (removed my comments) – qwerty_so Apr 24 '20 at 13:19
4

The norms says on p. 101:

Inherited members may also be shown in a lighter color to help distinguish them from non-inherited members. A conforming implementation does not need to provide this option.

Sadly, my tool (EA) does not support that.

The simplest method is to duplicate only the operation signatures of those operations you are going to override. That will make it clear that you are overidding something.

enter image description here

By just looking to Class2 there is no way to tell that b is actually an override. However, if someone wants to deal with Class2 he must know that it's a subclass - and thus will know that b is an override.


Note: The UML 2.5 specs are ambigous about the caret use. While (on p. 100) they say

Members that are inherited by a Classifier may be shown on a diagram of that Classifier by prepending a caret ’^’ symbol ...

the syntax below explictely mentions only properties and connectors and this passage

Analogous notations may be used for all NamedElements that are inheritedMembers of a Classifier to indicate that they are inherited.

qwerty_so
  • 35,448
  • 8
  • 62
  • 86