4

i have to draw some sequence diagrams for a software i wrote. In my Software i have some Objects that dispatch custom Events and other Objects that listens for these events.

When it comes to illustrate Eventlisteners und dispatchEvent-function i'm a little bit confused how to do that. I googled a lot, but couldn't find the right hint :(

Or is a sequence diagram not a good choice for explaining event handling?

Thanks for your help!

skaffman
  • 398,947
  • 96
  • 818
  • 769
thomas
  • 41
  • 1
  • 2

2 Answers2

2

There is no definitive answer to your question, because creating useful diagrams largely depends on what kind of information you want to convey to the reader. My advice is: You will never be able to show all your program's functionality in just one diagram; event handling is often too complex and ugly - try to split it up into smaller parts and decide individually, which kind of diagram is useful for which aspects you want to show.

For each one, your focus should always be on the reader: What do you want him or her to understand?

To start with, it's usually best to write user stories and show use cases, if you don't have those already. They convey the functionality your program was made for, and help you to identify processes and organize the way in which you think about your program. For each of those processes, a sequence diagram is probably most useful to show how things work. For example, if one of your program features is uploading an image, you should draw a sequence diagram showing the main components, objects and sequences of events involved only in the upload procedure.

The next step is to categorize the remaining events and objects, which are more fine-grained or do not interact directly with the user: Which events are internal (i.e. dispatched and handled within the same object), which are external (between some objects), or even global (affecting the entire application). This will help you to identify groups of objects interacting with one another.
Depending on how complex an object is, I often display internal event sequences within a state diagram or flow chart.

If you have some smaller object groups where the interactions are not too complex and more interesting in terms of who does what why instead of when, you can possibly use slightly altered class diagrams - these might not be very formal, but for some concepts, they are often more useful than flow charts, state or sequence diagrams.

It should also be mentioned, that in some cases, a diagram doesn't really help at all. Sometimes it is far more useful to write a short text providing an example, or collect information in tables. Documentation is complete, when a reader understands the concepts of what your program does and how it does so. For everything else, there is always the source code.

weltraumpirat
  • 22,544
  • 5
  • 40
  • 54
  • would you have any link / example to flow charts for an actionscript 3 projects/application i.e a basic event handling program – Aditya P Mar 28 '12 at 11:45
  • What would you consider a "basic event handling program"? Just about any even remotely advanced AS3 program will use event handling. Also, there would probably not be a single flow chart for the whole application, but rather several charts describing core patterns and/or concepts used. Did you even read my answer? – weltraumpirat Mar 28 '12 at 14:03
  • yes i had read your answer, i had gone with block level diagram for representing the core concepts in a class that i could represent ,but with no actual flow between them except for specific situations of preliminary class instantiation. i.e the way you have said it in your first step. what i am looking for a better way to represent is the next step that you mention – Aditya P Apr 01 '12 at 10:57
  • 1
    Internal event flow and states of an object can easily be represented as a flow chart - that is, in fact, a finite state machine: http://en.wikipedia.org/wiki/Finite-state_machine . An event triggers a transition between states. Perhaps that will help you along the way. – weltraumpirat Apr 01 '12 at 13:13
0

I don't know exactly what you are trying to do here but sequence diagrams are perfectly capable of representing the sort of system you have described. Here is an article on sequence diagrams. Look at the section on asynchronous messages and concurrency. Another article actually has an example of an event listener. It talks about both sequence and class diagrams. I guess the example of sequence diagrams will be of interest to you.

Community
  • 1
  • 1
341008
  • 9,862
  • 11
  • 52
  • 84