130 likes | 893 Views
Proposed Notation for Exception Handling in UML 2 Sequence Diagrams. Oddleif Halvorsen Øystein Haugen. What are UML 2 Sequence Diagrams?. Describe interaction sequences Emphasize the interaction between objects Partial descriptions
E N D
Proposed Notation for Exception Handling in UML 2 Sequence Diagrams Oddleif Halvorsen Øystein Haugen
What are UML 2 Sequence Diagrams? • Describe interaction sequences • Emphasize the interaction between objects • Partial descriptions • May be used to verify interaction properties with respect to a specification Send event Receive event Asynchronous message Halvorsen / Haugen
Why the Need for Exception Handling? ”This basic description of an object cannot be cluttered up with all of the details needed for handling the contingencies.” - Terry Winograd (1979) Halvorsen / Haugen
Challenges wrt. Seq. Diagrams and Exceptions • How to visually isolate exception handling from a sequence diagram without disturbing the current semantics? • Sequence diagrams are often used to describe distributed and multithreaded environments • The scope of exception handling in modern programming languages is normally limited to one call stack • Sequence diagrams describes sets of traces • There is no call stack Halvorsen / Haugen
Example Scene – Withdrawal of money from an ATM • Happy Day Scenario • Enter a card • Give the correct pin • Select a legal amount to withdraw • Receive the money and the card • Exceptions • Unrecognized card • Wrong pin • Selected too high amount to withdraw • ATM is out of money • Lost connection with the bank • Unable to deliver the money • Unable to give back card • ... Halvorsen / Haugen
Handling exceptions with current standard Ensuring correct pin. Preventing the user from withdrawing more than allowed. No valid pin given. Halvorsen / Haugen
Guard that triggers the exception. Reference to a diagram that handles the exception. Our Way The normal flow Adding exception flow without obstructing the normal flow Halvorsen / Haugen
Dynamic Gate Matching If a gate can be matched it is combined to complete the trace Recovered from the exception. Halvorsen / Haugen
Dynamic Gate Matching (continued) The normal flow diagrams Exception handling with dynamic gate matching Halvorsen / Haugen
The Diagram Stack Third attempt, correct pin. • Example stack • The user enters wrong pin twice • Correct pin the third time • Each frame represent a new separate layer of diagrams. • Move between frames through the use of exception and return. Second attempt, wrong pin. The trace can now continue with the normal flow. First attempt, wrong pin. Halvorsen / Haugen
Trace Semantics c: exception a: events executed before the exception <q>: trigger b: events enabled before the exception d: events after the exception • Without exceptions: U = <!m, ?m> seq <!n, ?n> • Disregarding the exception: U = a seq <q> seq b seq d • Recoverable exception: • b is a subtrace such that b contains no events on the same lifeline as that of q • c [[e]] i.e. c is a trace in the exception • Provided d is not empty, it starts with an event on the same lifeline as q • U = a seq <q> seq (b par c) seq d where a,b,c,d are (sub)traces and seq is trace concatenation and par represents all possible merge combinations Halvorsen / Haugen
Conclusion • Properties of our concepts of exception in UML Seq. Diag • Compact notation • Clear visual separation between the normal flow and the exception handling • Underpinned by precise semantics • May describe exception handling in synchronous as well as multithreaded and distributed scenarios Halvorsen / Haugen