How to show event in a sequence diagram

2020-07-06 02:19发布

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

标签: modeling uml
2条回答
女痞
2楼-- · 2020-07-06 02:54

What you want to do is possible but unusual. Typically these interactions would be provided by the existing system/platform and it would therefore not be necessary to include it in the application design.

Introduces how this would typically be documented

I would probably use a collaboration digram to do it.

If you insist on Sequence Diagrams figure 2 should help

查看更多
地球回转人心会变
3楼-- · 2020-07-06 02:54

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.

查看更多
登录 后发表回答