Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Representing overloaded methods in UML

I am attempting to create a UML diagram representative of some Java code.

In a class I have a method that is overloaded.

As far as I know, parameters for methods aren't shown in UML diagrams.

How do I represent method overloading in UML?

Thanks.

like image 1000
Mat Kelly Avatar asked Dec 01 '08 00:12

Mat Kelly


People also ask

What is an example of overloaded method?

In Java, two or more methods may have the same name if they differ in parameters (different number of parameters, different types of parameters, or both). These methods are called overloaded methods and this feature is called method overloading. For example: void func() { ... }

How do I show a method overriding in UML?

Switch to Operations tab and select the operation from superclass (indicated in Classifier column) which you wish to override. Press the Override button and you will see the Classifier of the operation changed form superclass to subclass. Now the method is being overridden and show in the subclass.

How can you distinguish 2 overloaded methods?

The compiler distinguishes overloaded methods by their signatures—a combination of the method's name and the number, types and order of its parameters, but not its return type. If the compiler looked only at method names during compilation, the code in Fig.

Can overloaded methods be in different classes?

Usually, method overloading happens inside a single class, but a method can also be treated as overloaded in the subclass of that class — because the subclass inherits one version of the method from the parent class and then can have another overloaded version in its class definition.


1 Answers

In the sub class you specify the method with the same signature as the method you wish to override and add a note {redefines} to the method. For example:

+doSomething(p:AThing):int{redefines}

This implies that doSomething() method overrides the method in a super class. And yes, parameters for methods are shown on diagrams. As in the example p is a paremeter of type AThing.

like image 59
Vincent Ramdhanie Avatar answered Nov 07 '22 09:11

Vincent Ramdhanie