4

In the UML specification 2.5.1 (Link) on page 117 it is specified that the notation of operations (methods) should look like the following:

[<visibility>] <name> ‘(‘ [<parameter-list>] ‘)’ [‘:’ [<return-type>] [‘[‘ <multiplicity-range> ‘]’]
 [‘{‘ <oper-property> [‘,’ <oper-property>]* ‘}’]]

What irritates me are the blanks. If I set them as described in the specification above, then they are unfortunately not consistent with the example found in the same chapter on page 119. Here the example looks like the following:

+createWindow (location: Coordinates, container: Container [0..1]): Window

See for instance: In the example, there is no blank between the <visibility> and the <name> but in the specification, there is a blank between them.

Can someone help me understand this inconsistency? Why are the blanks set so strangely anyway? If one wants to make it 100% correct, how would the blanks be set?

Kind Regards and Thanks, Raphael

Raphael
  • 151
  • 3

1 Answers1

5

The blanks in the specification of the notation are only there to separate the tokens for readability. If they Would be mandatory, they would have been added between quotes as literals (e.g. ‘ ‘, ‘:’, ...) as expected for all terminal symbols (see notational conventions page 16 and 17 and in particular "all terminals are enclosed between single quotes").

This practice is by the way very common in grammar specification of programming language and BNF-like notations.

This being said, the blanks are not meaningful in UML nor in its contraint companion OCL. This is why you’ll find several variants in the examples. It’s even a common practice not to add any blank.

Christophe
  • 74,672
  • 10
  • 115
  • 187
  • Actually on pp. 16 of UML 2.5 they describe the syntax notation in detail (as variant of BNF). –  Jan 05 '21 at 00:17