Question

I was wondering what is the best way to represent a function that is passed as a parameter in UML. Because I want to create a sequence diagram of my current networking code in my Swift project and some functions pass a function as parameter to other functions. So I was wondering is their a standard way to describe it in UML, or can I use swift syntax in my UML.

Was it helpful?

Solution

If a caller passes a function pointer to a callee, it is essentially defining a callback. You may need to represent it as all of the following:

  1. A member variable of the message payload
  2. A member of the class receiving the payload, since the target of the callback is a type of state
  3. A dependency from the callee to the caller
  4. An interface on the caller (who will receive the callback)

See also this post.

OTHER TIPS

If you use a programming language in which functions are first-class citizens (Swift, for instance), they basically are variables. Therefore, you should consider them as variables, even in a UML diagram.

Licensed under: CC-BY-SA with attribution
scroll top