Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Modelling the idea of throwing an exception in a UML Activity Diagram

The ability to model the idea of catching an exception is pretty easy in a UML activity diagram - but what about THROWING the exception? The closest thing I can seem to find would be the throwing activity sending a signal with a stereotype of <<exception>> and then hitting a flow-final node, but I don't know that this is considered best-practice. Any thoughts?

Thanks.

like image 778
rybosome Avatar asked Jun 29 '11 14:06

rybosome


People also ask

How can you express exception in UML diagram?

Exceptions are shown either in activity or in sequence diagrams. Here an alt fragment is used where the upper part shows the exception behavior and the lower part the normal result. Note that this is a simple on-the-fly sketch. Action corresponds to a method in a class (given in brackets below the name).

How to model exception handling in sequence Diagram?

UML provides neither notation to model exception handling in sequence diagrams nor any reasoning why it is absent. Some clumsy approaches to model try-catch blocks are by utilizing combined fragments - alt (alternatives) and breaks, while adding stereotypes for reply messages representing thrown exceptions.

What is Activity diagram explain with example?

Activity diagram is basically a flowchart to represent the flow from one activity to another activity. The activity can be described as an operation of the system. The control flow is drawn from one operation to another. This flow can be sequential, branched, or concurrent.


2 Answers

UML 2.4 superstructure specification, in chapter 12.3.44 Pin (from BasicActivities, CompleteActivities), on figure 12.122 (page 416), you can see output pin for throwing exceptions. There is also an example on figure 12.129 (page 419).

like image 177
Gabriel Ščerbák Avatar answered Sep 23 '22 06:09

Gabriel Ščerbák


UML notation exists to show exceptions. Look at Larman's book:

Applying UML and Patterns: An Introduction to Object-Oriented Analysis and Design and Iterative Development, Third Edition By Craig Larman 35.3. Handling Failure Chapter

Larman says that :

*In summary, UML notation exists to show exceptions. However, it is rarely used. *This is not a recommendation to avoid early consideration of exception handling.* Quite the opposite: At an architectural level, the basic patterns, policies, and collaborations for exception handling need to be established early, because it is awkward to insert exception handling as an afterthought. However, the low-level design of handling particular exceptions is felt by many developers to be most appropriately decided during programming or via less detailed design descriptions, rather than via detailed UML diagrams.*

like image 45
Novalis Avatar answered Sep 23 '22 06:09

Novalis