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.
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.
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.
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.
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.
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.
@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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With