23

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?

3 Answers 3

24

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>

where <property> is specified in 9.5.4.

Similarly, the notation for an inherited Connector is defined like this:

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

where <connector> is specified in 11.2.4.

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

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.

Since it applies for NamedElements it can be used for attributes and operations as well.

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.

0
21

See @qwerty_so answer for more up to date spec. The notation I propose below comes from outdated diagramming textbooks and college instruction from before 2008.

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

+ toString() : String <<override>>
4
  • 2
    please note that <<override>> is not define in UML specification document, so to use, normally you should define a profile or used an already existing profile which defines this stereotype.
    – granier
    Mar 8, 2017 at 17:41
  • Are profiles defined in the UML standard or would this be a feature of diagramming software? @granier
    – ThisClark
    Mar 17, 2017 at 14:33
  • Profiles are defined in the UML spec (quite extensively). There is a bit of freedom they let the SW developers to render stereotypes. But basically it's fully described.
    – qwerty_so
    Aug 13, 2021 at 18:24
  • On. p 260 of UML 2.5 it is stated: the name of the Stereotype is shown within a pair of guillemets above or before the name of the model element So the above is incorrect (besides the fact that the stereotype must belong to some profile).
    – qwerty_so
    Jan 15, 2022 at 15:16
8

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

1
  • Indeed, this is what UML calls an implicit redefinition (override): "Feature redefinitions may either be explicitly notated with the use of a {redefines <x>} (...) on the Feature or implicitly by having a Feature which cannot be distinguished (...) from another Feature in one of the owning Classifier’s more general Classifiers"
    – Christophe
    Jan 15, 2022 at 11:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.