50092

Override method in uml

<h3>Question</h3>

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?


<h3>Answer1:</h3>

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

[edit]

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

[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


<h3>Answer2:</h3>

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.


<h3>Answer3:</h3>

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.

<hr />

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>

来源:https://stackoverflow.com/questions/61398067/override-method-in-uml

Recommend

  • JavaScript equivalent to composer
  • #Error showing up in multiple LEFT JOIN statement Access query when value should be NULL
  • What is the difference between ViewData, ViewBag and TempData? [duplicate]
  • Why DbSet doesn't implement EnumerableAsync
  • Failed to execute 'getComputedStyle' on 'Window': parameter 1 is not of type �
  • How to add different enum values to a Set as unique entities?
  • Object browser in vba7 does not show WebClient Object members [duplicate]
  • Troubleshooting HTTPClient asynchronous POST and reading results
  • How to deploy a COM
  • How to get yyyy-mm-dd hh:mm:ss format from 28 Jul 2011 22:33:57 in iPhone?
  • Spring batch pause/resume vs stop/restart
  • Unable to create a textclip in moviepy (imagemagick succesfully installed?) - got Utf8 Error
  • Microsoft bot framework webchat C#
  • can I build CMakeLists.txt from a set of smaller files (to improve the readability and maintainabili
  • How to copy memory
  • React/Redux. Access state from other component
  • date changes on export kendoGrid
  • Expression.Call GroupBy then Select and Count()?
  • Adding Dynamic Row and Data on Checkbox Click
  • Populating a database table with returned JSON
  • Tkinter tkMessageBox disables Tkinter key bindings
  • Bundling python(“.py”)files along with java class files for a web application
  • NoClassDefFoundError: com.google.gson.GsonBuilder when using google play services with microsoft azu
  • Unable to run testNG tests from maven
  • Excel File upload in asp.net using SqlBulkCopy
  • How to make Rss News Reader application in android …? [closed]
  • Copy and paste data from multiple workbooks to a worksheet in another Workbook
  • Request Access Token in Postman for Azure Function App protected by Azure AD B2C
  • When to use the tag in the head and body section of a html page? [duplicate]
  • java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/SpringDispatcher-ser
  • how to get the location(lat/lng) on google maps v3 from the location(x,y)
  • Codeigniniter insert data through models and controller
  • Passing value from popup window to parent form's TextBox
  • How do I use TagLib-Sharp to write custom (PRIV) ID3 frames?
  • WPF custom control and direct content support
  • CAS 4 - Not able to retrieve the LDAP groups after successful authentication
  • Spring Boot not autowiring @Repository
  • Access to a Matlab gui from the web
  • ReferenceError: TextEncoder is not defined