UML – Class Diagram Symbol for a Top-Level Function

uml

In UML class diagram notation, how do I denote a top-level function that doesn't have any encapsulating class or other structure?

e.g. I have a function used for retrieving data from a URL. Since it is a function (in the math sense) of only its parameters and a shared global state, the function is not put in a class but left as a top-level method.

Now though, I need to create a UML diagram for a program using it, and I can't find anything about how to denote a top-level function. How do I do this?

Best Answer

Create a stereotype that you can attach to the "class" classifier, e.g., <<global function>>. You can then create a single stereotyped "class" for each global function containing one fully specified static operation.

The stereotype I propose tells the person reading the diagram to interpret the classifier as a function. The rectangle (with the stereotype) on a given diagram would represent a single function, while its dependencies represent the dependencies of that single function.