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.
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:
- A member variable of the message payload
- A member of the class receiving the payload, since the target of the callback is a type of state
- A dependency from the callee to the caller
- An interface on the caller (who will receive the callback)
See also this post.