Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to present static class or function call in Sequence Diagram?

How is a static class or call to a static function presented in Sequence Diagram? As per my understanding, the lifeline belongs to an instance/object of a class. This article says metaclass stereotype can be used.

like image 962
bjan Avatar asked Feb 02 '12 07:02

bjan


People also ask

How do you represent static in a class diagram?

Class (i.e. static) methods and fields are indicated by underlining. Constant (i.e. final) fields are indicated via naming convention: constants should be in ALL_CAPS.

How do you represent a function call in UML?

Sequence diagrams are appropriate to represent function calls, and you can specify the parameters and returned values as well. Save this answer. Show activity on this post. Communication Diagrams are also an option and tend to go into more detail with regards to parameters used within function calls.

How do you call a static function?

Calling Static FunctionIt is invoked by using the class name. For example: Math. sqrt(a); //calling the square root function of the Math class.

Is sequence diagram static or dynamic?

There are two kinds of object models: dynamic and static. Dynamic models, such as UML interaction diagrams (sequence diagrams or communication diagrams), help design the logic, the behavior of the code or the method bodies. They tend to be the more interesting, difficult, important diagrams to create.


1 Answers

"In case of doubt, use comments, or stereotypes..."

Sequence Diagram:

+-------------+           +-------------------+
|  <<class>>  |           |     <<class>>     |
|     Cat     |           |  FastFoodTerminal |
+------+------+           +---------+---------+
       |                            |
       |          <<static>>        |
       |           TurnOn()         |
       +--------------------------->+---+
       |                            |   |
       +<---------------------------+<--+
       |                            |
       |       Answer   =           |
       |  DoYouHaveCheeseBurger()   |
       +--------------------------->+---+
       |                            |   |
       +<---------------------------+<--+
       |                            |

Class Diagram:

+-------------------------------------------------+
|                    <<class>>                    |
|                FastFoodTerminal                 |
+-------------------------------------------------+
| [+] void: FastFoodTerminal();   <<constructor>> |
| [#] int: ObtainMoneyDifference();               |
| [+] void: ReceiveMoney();                       |
| [+] void: ReturnChange();                       |
| [+] FastFoodTerminal: TurnOn(); <<static>>      |
+-------------------------------------------------+

In this example, the "TurnOn()" is an static method that returns, an instance (object) of the "FastFoodTerminal" class.

like image 122
umlcat Avatar answered Oct 20 '22 10:10

umlcat