BMD
BMD

Reputation: 11

Terminate activity diagram from subactivity

I´m trying to draw an UML activity diagram for a fnction that is (highly simplified) represented by the following code snippet. My intention is to have a subactivity for the lines that check the mode parameter (if-else).

ErrorType DoSomething(int mode) {

    if(mode==MODE1) {
        ...
    }
    else {
        return MODE_NOT_AVAILABLE;
    }

    SomethingElse...

    return NO_ERROR;
 }

You can see, the return-Statement in the else-Block leads to termination of function DoSomething. So if it´s executed, there is no way for SomethingElse... to be executed.

As I mentioned, this else-block should be in a subactivity. How do I visualize that an action in a subactivity (return MODE_NOT_AVAILABLE) has the consequence that it´s parental activity diagram has to be in a final state?

In the following picture you can see my try to solve it. Is this a correct solution?

UML activity diagram

Upvotes: 1

Views: 362

Answers (1)

observer
observer

Reputation: 3005

Since you are dealing with some kind of exception, I'd model it with an exception handler like you see here http://www.sparxsystems.com.au/images/screenshots/uml2_tutorial/ad11.GIF. Even though your concrete implementation uses if/else, that should be a way which makes it easy to understand what you want to achieve (prevent the subroutine from being executed in wrong mode).

You can see more details about the notation here: http://edn.embarcadero.com/article/30169

It depends on how much you want to dictate the actual implementation. UML itself is langage-unaware, and so are most stakeholders.

Upvotes: 1

Related Questions