Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to show usage of static methods UML Class Diagram

Tags:

How do i show the use of static methods in a UML class diagram?

class A{     public static void test(){     } }  class B{     public void b(){     A.test();     } } 

How would a class diagram look like, which shows the relationship? UML 2.0 would be prepared, if there is a difference.

like image 526
Nicolas Avatar asked Jun 26 '12 14:06

Nicolas


People also ask

How do you show static methods in a class diagram?

The UML denotes static features by underlining the feature in the class diagram. Programmers translate the underlining to the static keyword when they translate the UML class diagram to C++. Denoting static features in a UML class diagram. The UML denotes static features by underlining them.

Which UML diagram shows the static view?

Object-Oriented Analysis, Design and Programming with UMLClass diagram is a static diagram. It represents the static view of an application. Class diagram is not only used for visualizing, describing, and documenting different aspects of a system but also for constructing executable code of the software application.

How do you show methods in a class diagram?

On a class diagram, public messages (and any public attributes) are shown with a plus sign ( ) in front of them. Methods also have parentheses after them, indicating that data may be passed as parameters along with the message. The message parameters, as well as the type of data, may be included on the class diagram.

What is static in class diagram?

A static attribute or operation is an attribute or operation belonging to a class rather than the instances of the class. A utility or service is a class containing only static members. For example, a Trig utility class might contain sin and cos methods as well as the constant PI.


2 Answers

To show a static method you underline the name of the static method - have a look here for more detailed info.

As for navigating that relationship; class B is dependent on the existance of class A. We can say that class B has a "usage dependency" on class A

class B ----uses----> class A 

Hope this helps.

like image 56
RobertMS Avatar answered Oct 07 '22 18:10

RobertMS


@RobertMS is right.

Another alternative, is to use stereotypes:

.............................................................. ....+----------------------------------------------------+.... ....|                StringUtilityClass                  |.... ....+----------------------------------------------------+.... ....| [+] void: lowerCase()              <<non virtual>> |.... ....| [+] void: upperCase()              <<non virtual>> |.... ....| [+] String: toString()                <<override>> |.... ....+----------------------------------------------------+.... ....| [+] String: LowerCaseCopy(String Value) <<static>> |.... ....| [+] String: UpperCaseCopy(String Value) <<static>> |.... ....| [+] String: ReverseCopy(String Value)   <<static>> |.... ....+----------------------------------------------------+.... .............................................................. 

Note Some programming languages best practices, especially those with C case-sensitive syntax, capitalize static functions, and leave in camel-lowercase the rest of functions.

Cheers.

like image 41
umlcat Avatar answered Oct 07 '22 17:10

umlcat