12

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.

bjan
  • 2,000
  • 7
  • 32
  • 64
  • [UML 2 Sequence Diagrams:](http://www.agilemodeling.com/artifacts/sequenceDiagram.htm) `Notice how object labels are underlined, classes and actors are not` It sounds like static class or call to a static function is represented with same stereotype provided 1- the _name_ part of the pattern _name:ClassName_ should be empty 2- It should not be underlined – bjan Feb 02 '12 at 10:07
  • No sure, but, I think some tools, additionally, use rounded edges for the rectangle, in case of objects. – umlcat Feb 03 '12 at 05:49

3 Answers3

9

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

DPWork
  • 446
  • 3
  • 16
umlcat
  • 4,091
  • 3
  • 19
  • 29
7

So finally it is the use of stereotype to mention a static class/function. Underlining is no more applicable in UML 2.4.1 Aug 2011, page Page 86, under the headings Notation and Presentation Options

bjan
  • 2,000
  • 7
  • 32
  • 64
  • (+1) Good to hear about it. When modeling on a whiteboard / blackboard, or a notebook, underlining is not very clear. Same goes for cursive notation ... – umlcat Oct 14 '14 at 19:16
4

I think your comment covers most of it:

UML 2 Sequence Diagrams: Notice how object labels are underlined, classes and actors are not It sounds like static class or call to a static function is represented with same stereotype provided 1- the name part of the pattern name:ClassName should be empty 2- It should not be underlined.

UML cannot cover this entirely because static is not a UML definition, each language has slight variances. However the UML spec for "features"[pg. 69] (attr/operations):

isStatic: Boolean -- Specifies whether this feature characterizes individual instances classified by the classifier (false) or the classifier itself (true). Default value is false.

Notice that they say the classifier itself. So the question is can I put a classifier a sequence diagram, not an instance? Also notice that is does not say classifier can be static. Page 27 of the same UML spec shows no isStatic in the meta class "classifier" (class). So UML does not provide a formal model feature for static classes. You can use stereotype or keywords, or your own UML profile and extend Class. But the short answer is do what you already posted.

Ted Johnson
  • 4,315
  • 3
  • 29
  • 31
  • [UML 2.4.1 Aug 2011](http://www.omg.org/spec/UML/2.4.1/Superstructure/PDF), Page 86, under the headings `Notation` and `Presentation Options`, it looks conflicting with my comments or that referred article is no more valid after this release of UML 2 – bjan Feb 03 '12 at 06:02