Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to represent an event based architecture in a static UML model?

Tags:

events

uml

I have a fairly basic C# event based system but I'm not sure how I model it in UML. I obviosuly want to show the event publisher, subscriber, handlers and EventArgs classes .. I think you use 'signals' but I can't find any examples. Can anyone point me to an example or shed any light?

Thanks

Edit: I am creating a static model, I don't need to represent state or paths through the process. Sorry If i didn't make that clear in the initial question..

like image 439
flesh Avatar asked Jul 13 '09 15:07

flesh


2 Answers

The "Publisher-Subscriber" pair pattern (a.k.a "Observer"), may be implemented different in each programming (language) framework, therefore, designed different, in U.M.L.

Any way, conceptually, when an event ("signal" or "message") is sent, from a publisher (a.k.a "server") to any subscriber ("client"), sometimes, an "id" to identify a particular event, from other events, its provided, and some additional parameters or data its also sent.

As other answers already mention, you may require a (class) diagram to describe the static model. (Note that there is a "aggregation", not "composition", "association" can be used):

..............................
+--------------------------+..
|      <<Publisher>>       |..
|      VectorDrawApp       |..
+--------------------------+..
| [+] create()             |..
+--------------------------+..
| [+] send(EventArgs e)    |..
+------------+-------------+..
............/ \...............
............\ /...............
.............|................
.............|................
+------------+-------------+..
|      <<Subscriber>>      |..
|          Figure          |..
+--------------------------+..
| [+] create()             |..
+--------------------------+..
| [+] receive(EventArgs e) |..
+--------------------------+..
..............................
+--------------------------+..
|        <<Event>>         |..
|        EventArgs         |..
+--------------------------+..
| [+] Sender: TObject      |..
+--------------------------+..
| [+] receive(EventArgs e) |..
+------------+-------------+..
.............|................
.............+................
............/ \...............
...........+---+..............
.............|................
+------------+-------------+..
|        <<Event>>         |..
|  FillEventArgs: EventArgs|..
+--------------------------+..
| [+] ForeColor            |..
| [+] BackColor            |..
| [+] FillStyle            |..
+--------------------------+..
..............................

And also, you may require a diagram to describe the dynamic model:

.........................................
+----------------+..+----------------+...
| <<Publisher>>  |..| <<Subscriber>> |...
|  VectorDrawApp |..|      Figure    |...
+--------+-------+..+--------+-------+...
.........|...................|...........
.......+-+-+...............+-+-+.........
.......|   |...send(fill)..|   |..Fill().
.......|   +==============>+   +---+.....
.......|   |...............|   |...|.....
.......|   |...<<return>>..|   |...|.....
.......|   |<--------------+   +<--+.....
.......|   |...............|   |.........
.......+-+-+...............+-+-+.........
.........|...................|...........
.........X...................X...........
.........................................

Stereotypes, in U.M.L., are your "drinking buddies", and allow you to describe or restrict what an actor, object, class, trait, or interface does.

When you use them, highlight when an object or class, are subclasses of a class, or implement, an interface that is relevant to the activities, that are been model, even if there are other parent classes, or interfaces.

Cheers.

like image 117
umlcat Avatar answered Oct 16 '22 11:10

umlcat


As indicated by lexu and John, you can use statecharts and activity diagrams to model some of the dynamic aspects of your system.

For your static model, you can model the events a class can handle as operations. You can use a stereotype (<<event>>) to differentiate these operations from others (e.g. synchronously called methods).

like image 39
Brandon E Taylor Avatar answered Oct 16 '22 12:10

Brandon E Taylor