0

I am about to make a UML activity diagram for an old program, full of goto. The program I'm going to model is constructed as in the example. First, it make something, then it check the error flag. And if the error flag is set, it writes an error code to a log and possibly go to another place in the program.

// When error, the program generate a Trap and then go to 1000
err = Foo(A,B,C)
if (err != 0) 
{
   CTrap(2000,err,A,B,C)
   goto(1000)
}

// When error, the program generate a trap and continue
err = Foo2(A,B,C)
if (err != 0)
{
   CTrap(2000,err,A,B,C)
}

CTrap writes an error code to the log, and I want the activity diagram to show the error codes that each activity can generate and when.

Now I have tried modeled this with countless of decisions and merges and added an action for each error code that is written to the log. But it is almost impossible to follow the program then. I could remove the action for the error codes, but then I lose important information. And it is then still countless decisions and merge. I wonder if there is any notation that I can use to simplify it somehow. So it shows the error codes that can be generated and when, without having to flood the chart with decisions and merges. If I can use the post-contion on the error flag in any way, or if you can have multiple outputs from a campaign with conditions on?

Edit

I've experimented a bit by placing information about error codes (Trap) in the comments. I do not know if it is possible to write as I have done? And can I have different outputs from an activity that I have done in some places? Then I wonder if I've been using the "Write Variable" correct? This has been said one experiment, and not a complete diagram.

The functions that is prefixed with BFX is system functions, and function prefixed with BX2 are functions associated with this program. All merge is a GOTO destination. For example the merge called 8100 is a part of the program that handle error situations that you go to with GOTO 8100

My experiment

magol
  • 6,135
  • 17
  • 65
  • 120
  • What are you modeling as actions? each function? – vainolo Oct 13 '12 at 18:30
  • In the example, it is the calls to Foo1 and Foo2. But it can also be a number of calls to functions, and other operations. But the program always check for each such "action" if Err is set and if so, generates a Trap – magol Oct 14 '12 at 20:15
  • Sorry but I still cannot understand what you are trying to do. – vainolo Oct 14 '12 at 20:18
  • I apologize I'm unclear. Thank you for trying to help me :-) I edit the question a little to clarify the issue a bit. I hope this makes it clearer. Otherwise, feel free to ask again – magol Oct 14 '12 at 20:37

1 Answers1

1

You can do this using multiple activity diagrams. From your code, you don't want to show the possible errors on the top level diagram, but on the diagram that shows CTrap you can show the possible error codes and what they do.

If you want to show all the information in one diagram there is nothing you can do - the diagram will become pretty cluttered.

Edit (after addition of diagram): you can concatenate the guards in the links so instead of having 4 links outgoing from the junction you get one. Don't think that there is anything else that you can do.

vainolo
  • 6,907
  • 4
  • 24
  • 47
  • Thanks for your reply. I guess unfortunately, you're right. But I still made ​​an effort to make some simplifications anyway. See my edit of my question. Probably I'm completely wrong, but it's an attempt anyway. CTrap is a system call, so I will unfortunately not do any diagrams for it. – magol Oct 15 '12 at 09:34
  • Can you post an example diagram? – vainolo Oct 15 '12 at 09:50
  • Is the graph correctly otherwise? Is it possible to do as I have done? I myself think that I have stretched a bit on the UML standard. – magol Oct 15 '12 at 12:52
  • Looks OK. The UML "standard" was made to be stretched :-). In my opinion the best way to check the diagram's validity is to pass it around to your co-workers and if they understand it then it is good. – vainolo Oct 15 '12 at 13:05
  • Thank you so much for your help. I did not think UML was so flexible. Then I can continue to try to complete the documentation of the spaghetti code in this way. – magol Oct 15 '12 at 13:14