How to show event in a sequence diagram

modelinguml

I want to draw a sequence diagram and I want to show interaction between user and UI. User as an actor would fill a text box and on text_change event an asynchronous method of BL class would call. In this case is it possible to show text_change event on the diagram? and how can I show it?

thanks

Best Answer

To represent interactions in a more or less complex and GUI-rich applications I, too, often found myself interested in representing .NET events in sequence diagrams. To my view, there is no really descriptive way to effectively do it using standard means.

A formally justifiable way could be as follows: raising an event is basically nothing but calling a defined function in the target instance, the only difference is that you call it not directly, but via the system event message loop. So, behind the scenes, raising an event is identical to calling some HandleMessage("MyEvent", params object[] args) function in the system itself, the parameters being the name of the event and a list of optional arguments. I do not know what the exact name and signature are, but this does not really matter.

A representation of .NET event on an UML sequence diagram

In the above figure, a Source instance issues an event MyEvent with a list of arguments that lands on the system receiver. The receiver finds the addressee (Target) and calls its corresponding method (Target.OnMyEvent()). To emphasize that this call is event-triggered, I introduce a stereotype called "Event".

This scheme may look somewhat clumsy, but, to me, it covers the case.

Related Topic