State Diagrams Example Finite State Machine Representation Part of a purchase protocol that deals with making offers ◮ Roles: buyer (b) and seller (s) S 0 S 3 ◮ Transitions labeled with messages ◮ Specify legal message flows offer(s, b) reject(b, s) S 1 accept(b, s) update(s, b) S 2 Munindar P. Singh (NCSU) Service-Oriented Computing Fall 2018 193
State Diagrams Finite State Machine (NetBill Protocol) Legitimate protocol: specifies interactions, not internal decision making ◮ Roles: merchant ( mer ) S 0 S 3 and customer ( cus ) mer, cus: cus, mer: ◮ Transitions: messages offer(price, item) reject(price, item) sender, receiver cus, mer: ◮ Enactment: reject S 1 S 2 accept(price, item) ◮ Enactment: accept , mer, cus: deliver , pay deliver(item) ◮ Correctness: purely S 4 operational terms (sequences of messages, cus, mer: not meanings) pay(price) ◮ Excludes legitimate enactments (next S 5 picture) Munindar P. Singh (NCSU) Service-Oriented Computing Fall 2018 194
State Diagrams State Machine Example: Generalized S 0 S 3 mer, cus: cus, mer: offer(price, item) reject(price, item) cus, mer: S 1 S 2 accept(price, item) mer, cus: deliver(item) cus, mer: mer, cus: S 4 pay(price) pay(price) cus, mer: pay(price) cus, mer: cus, mer: S 6 S 5 S 7 deliver(item) deliver(item) Munindar P. Singh (NCSU) Service-Oriented Computing Fall 2018 195
State Diagrams Produce Ever-Larger FSMs with Additional Enactments? Can we not use FSMs to capture all reasonable paths? ◮ Complicates implementation ◮ Not runtime but hardwired flexibility ◮ Presupposes an arbitrary selection of paths: which path is reasonable, which is not? ◮ The same criticism applies to the low-level conception, even if specified declaratively in logic Munindar P. Singh (NCSU) Service-Oriented Computing Fall 2018 196
State Diagrams Evaluation of the FSM Representation Does not account for meanings of messages ◮ Flexibility: limited by over-specifying message order and occurrence ◮ Compliance checking: easy since the protocol is explicit about message order and occurrence ◮ Failure to comply may not indicate an application-level problem ◮ Implicit meanings: loss of interoperability due to inconsistent interpretations of messages ◮ Designers agree offline regarding the meanings, thereby limiting heterogeneity Munindar P. Singh (NCSU) Service-Oriented Computing Fall 2018 197
State Diagrams State Diagrams Formalized in UML 2.0 from Harel’s statecharts Generalize over finite state machines ◮ Condition or guard on a transition ◮ Superstate ( or -state): being in a substate entails being in the superstate ◮ Natural for summarizing states that bear similar meanings and support similar transitions ◮ Parallel states indicate being in the each of the states at the same time ( and -state) ◮ Cartesian product of the individual states ◮ Natural for expressing mutually independent components of the state Munindar P. Singh (NCSU) Service-Oriented Computing Fall 2018 198
State Diagrams Exercise: Diagram the Purchase Protocol First as we specified and second with concurrent Pay and Ship subprotocols Munindar P. Singh (NCSU) Service-Oriented Computing Fall 2018 199
State Diagrams Exercise: Diagram the Purchase Protocol with Return and Refund Munindar P. Singh (NCSU) Service-Oriented Computing Fall 2018 200
State Diagrams Exercise: Diagram Precedence, Occurrence, Exclusion Across two messages, m 1 and m 2 Munindar P. Singh (NCSU) Service-Oriented Computing Fall 2018 201
State Diagrams Applying State Diagrams in Our Setting Behavior descriptions, but of social behavior ◮ In general, sequence diagrams should describe interactions whereas state diagrams should describe internal behaviors ◮ Traditional sequence diagrams often step into internal details ◮ Traditional state diagrams are low-level, just as traditional sequence diagrams are, only more so ◮ Our state diagrams apply to a social state, which can be affected through messages described by sequence diagrams ◮ Consider state diagrams as describing the progression of the social state of a service engagement ◮ We can express this from an outside, i.e., a public or an institutional, as opposed to an implementation perspective ◮ A research challenge is to ensure the social state remains sufficiently aligned across the interacting parties ◮ For a properly designed service engagement, its social state ought to progress consistently Munindar P. Singh (NCSU) Service-Oriented Computing Fall 2018 202
Recommend
More recommend