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?
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 :<blockquote>
<em>Members</em> that are inherited by a <em>Classifier</em> may be shown on a diagram of that Classifier by prepending a caret ’^’ symbol to the textual representation that would be shown if the <em>member</em> were not inherited.</blockquote>
So, having :
B does not override <em>oper</em>
But having :
we cannot know except if we are sure the ^ is always used in the model as in previous diagram
Notice the norm use two times the words <em>member</em> (and not <em>properties</em>) in that sentence, and <em>Class</em> inherits (indirectly) <em>Classifier</em>, so that applies for operations.
As noticed in an other answer the norm says also :<blockquote>
Inherited <em>members</em> may <em>also</em> be shown in a lighter color to help distinguish them from non-inherited **members*.</blockquote>
so again two times <em>members</em> rather than <em>properties</em>, and the fact they use <em>also</em> clearly reference the fact there is an other way which is the ^. So <em>two</em> consistent sentences indicating ^ applies to operations
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
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.
The norms says on p. 101:<blockquote>
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.</blockquote>
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.
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 <em>must</em> 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<blockquote>
Members that are inherited by a Classifier may be shown on a diagram of that Classifier by prepending a caret ’^’ symbol ...</blockquote>
the syntax below explictely mentions only properties and connectors and this passage<blockquote>
Analogous notations may be used for all NamedElements that are inheritedMembers of a Classifier to indicate that they are inherited.</blockquote>