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

bjan picture bjan · Feb 2, 2012 · Viewed 25.9k times · Source

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.

Answer

umlcat picture umlcat · Feb 3, 2012

"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.