Outline Specification Approaches Munindar P. Singh (NCSU) - - PowerPoint PPT Presentation

outline
SMART_READER_LITE
LIVE PREVIEW

Outline Specification Approaches Munindar P. Singh (NCSU) - - PowerPoint PPT Presentation

Specification Approaches Outline Specification Approaches Munindar P. Singh (NCSU) Service-Oriented Computing Spring 2014 1 / 29 Specification Approaches Message Sequence Diagrams Outline Specification Approaches Message Sequence Diagrams


slide-1
SLIDE 1

Specification Approaches

Outline

Specification Approaches

Munindar P. Singh (NCSU) Service-Oriented Computing Spring 2014 1 / 29

slide-2
SLIDE 2

Specification Approaches Message Sequence Diagrams

Outline

Specification Approaches Message Sequence Diagrams Protocols and Policies State Diagrams

Munindar P. Singh (NCSU) Service-Oriented Computing Spring 2014 2 / 29

slide-3
SLIDE 3

Specification Approaches Message Sequence Diagrams

Sequence Diagrams

Well-known specification approach

◮ Originally used for object-oriented programming ◮ Our needs: closest to message sequence charts ◮ An intuitive way to express interactions

◮ Expresses global view consolidating local perspectives ◮ Excellent for describing possible interaction instances ◮ But beware the pitfalls . . .

◮ Support (potential) validation checks

◮ Formalizing semantics is not obvious: multiple approaches

◮ Standardized in UML 2.0 as Sequence Diagrams

◮ Caveat: Arrowheads and other details of these notes don’t necessarily

match UML

Munindar P. Singh (NCSU) Service-Oriented Computing Spring 2014 3 / 29

slide-4
SLIDE 4

Specification Approaches Message Sequence Diagrams

Method Invocation in Object-Oriented Programming

Only one thread of control; objects exchange messages

getBalance() balance getTotal() total c:Customer p:Portfolio a:Account

Munindar P. Singh (NCSU) Service-Oriented Computing Spring 2014 4 / 29

slide-5
SLIDE 5

Specification Approaches Message Sequence Diagrams

Message Emission and Reception

Independent threads of control; autonomous parties exchange messages, asynchronously sending and receiving

Request for Quote c:Customer m:Merchant

Munindar P. Singh (NCSU) Service-Oriented Computing Spring 2014 5 / 29

slide-6
SLIDE 6

Specification Approaches Message Sequence Diagrams

The Alternative Block

Nondeterministially choose and execute any fragment whose guard is true

Provide Quote Accept Quote Reject Quote c:Customer m:Merchant [¬Yes] alt [Yes]

Munindar P. Singh (NCSU) Service-Oriented Computing Spring 2014 6 / 29

slide-7
SLIDE 7

Specification Approaches Message Sequence Diagrams

The Optional Block

Modeling error here: Showing internal detail (free (spare time)) in a protocol

Provide Goods Pay Charges Submit Comments c:Customer m:Merchant

  • pt

[free]

Munindar P. Singh (NCSU) Service-Oriented Computing Spring 2014 7 / 29

slide-8
SLIDE 8

Specification Approaches Message Sequence Diagrams

The Loop Block

Usually bounded in our examples

Provide Goods Pay Charges Offer Counter Offer c:Customer m:Merchant loop [5 times]

Munindar P. Singh (NCSU) Service-Oriented Computing Spring 2014 8 / 29

slide-9
SLIDE 9

Specification Approaches Message Sequence Diagrams

Purchase (Just the Happy Path)

Notice the hand off pattern, indicative of delegation

Request for Quotes Quote Accept Ship Deliver c:Customer m:Merchant s:Shipper

Munindar P. Singh (NCSU) Service-Oriented Computing Spring 2014 9 / 29

slide-10
SLIDE 10

Specification Approaches Message Sequence Diagrams

The Parallel Block

Provide Goods Pay Charges Deliver Goods Request Payment c:Customer m:Merchant b:Bank [] par []

Munindar P. Singh (NCSU) Service-Oriented Computing Spring 2014 10 / 29

slide-11
SLIDE 11

Specification Approaches Message Sequence Diagrams

Exercise: Diagramming Precedence

◮ Four roles: A, B, C, D (could map to the same parties) ◮ Two messages: mAB and mCD (sender to receiver: distinct parties) ◮ We would like to assert that mAB precedes mCD

Munindar P. Singh (NCSU) Service-Oriented Computing Spring 2014 11 / 29

slide-12
SLIDE 12

Specification Approaches Message Sequence Diagrams

All Possible Sequence Diagrams

Given messages from a to b and from c to d

a = b c = d a = c b = d b = d a = c a = d b = c b = c a = d b = c b = c b = d b = d

Munindar P. Singh (NCSU) Service-Oriented Computing Spring 2014 12 / 29

slide-13
SLIDE 13

Specification Approaches Message Sequence Diagrams

Exercise: Which of the Precedence Diagrams are Compatible with Asynchrony?

Invariant outcomes regardless of relative execution speed, communication delays, and no global clock

Munindar P. Singh (NCSU) Service-Oriented Computing Spring 2014 13 / 29

slide-14
SLIDE 14

Specification Approaches Message Sequence Diagrams

Exercise: Diagramming Occurrence and Exclusion

Use guards that refer to message occurrence If [mAB] occurs then so does [mCD]

◮ Four roles: A, B, C, D (could map to the same parties) ◮ Two messages: mAB and mCD (sender to receiver) ◮ We would like to assert that

◮ mAB excludes mCD ◮ mAB and mCD mutually exclude each other ◮ mAB requires mCD Munindar P. Singh (NCSU) Service-Oriented Computing Spring 2014 14 / 29

slide-15
SLIDE 15

Specification Approaches Message Sequence Diagrams

Properties of a (Point-to-Point) Message Channel

Consider these questions

Noncreative: Must a message that is received have been sent before?

◮ Can we take a system snapshot that violates this

property? Reliable: Must a message that is sent be received?

◮ Can we take a system snapshot that violates this

property? Ordered: Must the messages received from the same sender be received in the order in which they were sent?

◮ In which direction does the information flow?

Causal: Must the messages received from different senders be received in the order in which they were sent?

◮ Can we take a system snapshot that violates this

property?

Munindar P. Singh (NCSU) Service-Oriented Computing Spring 2014 15 / 29

slide-16
SLIDE 16

Specification Approaches Message Sequence Diagrams

Challenges to Correctness of Protocols

Not specific to sequence diagrams

Distribution: different parties observe different messages, i.e., each lacks remote knowledge Asynchrony: different parties observe messages in inconsistent orders

◮ Despite FIFO channels ◮ Intuitions about correctness

◮ If each party interacts correctly, is the overall behavior correct? ◮ If not, our sequence diagram is not realizable or enactable ◮ Is the design of each party obvious? ◮ Does the design of the parties preclude some legal enactments? Munindar P. Singh (NCSU) Service-Oriented Computing Spring 2014 16 / 29

slide-17
SLIDE 17

Specification Approaches Protocols and Policies

Outline

Specification Approaches Message Sequence Diagrams Protocols and Policies State Diagrams

Munindar P. Singh (NCSU) Service-Oriented Computing Spring 2014 17 / 29

slide-18
SLIDE 18

Specification Approaches Protocols and Policies

Business Protocols

Interactions among autonomous parties, understood at the business level

◮ Conversation: An instance of a protocol ◮ Operational representations: steps taken

◮ Procedural ◮ Sequence diagrams ◮ State diagrams ◮ Activity diagrams ◮ Petri Nets ◮ Declarative ◮ Temporal logic ◮ Dynamic logic ◮ Information-based specifications

◮ Meaning-based representations: underlying business transaction

◮ Declarative, if captured formally at all ◮ Commitment machines ◮ Constitutive specifications Munindar P. Singh (NCSU) Service-Oriented Computing Spring 2014 18 / 29

slide-19
SLIDE 19

Specification Approaches Protocols and Policies

Exercise: Identify the Public and Private Components

Process = Protocol + Policies

Request for Quotes Quote Accept Ship Deliver c:Customer m:Merchant s:Shipper

Munindar P. Singh (NCSU) Service-Oriented Computing Spring 2014 19 / 29

slide-20
SLIDE 20

Specification Approaches Protocols and Policies

Exercise: How Might we Modularize Protocols?

Consider Purchase

Munindar P. Singh (NCSU) Service-Oriented Computing Spring 2014 20 / 29

slide-21
SLIDE 21

Specification Approaches Protocols and Policies

Modular Business Protocols

◮ Identify small, well-defined interactions with clear business meanings ◮ Improve flexibility and concurrency ◮ Possibly lead to invalid executions ◮ How can we ensure good properties despite modularity?

◮ Begin from a constraint language ◮ Standardize modular fragments as patterns, e.g., RosettaNet Munindar P. Singh (NCSU) Service-Oriented Computing Spring 2014 21 / 29

slide-22
SLIDE 22

Specification Approaches Protocols and Policies

Sequence Diagrams for Business Modeling

No!

◮ No internal reasoning

◮ No private predicates in guards

◮ No method calls

◮ No self calls

◮ No synchronous messages

◮ No business puts itself on indefinite hold waiting for its partner to

proceed

◮ No causally invalid expectations

◮ No nonlocal choice ◮ No nonlocal choice that matters ◮ No control of incoming message occurrence or ordering ◮ No dependence on occurrence or ordering of remote message emission

  • r reception

◮ No reliance on ordering across channels ◮ No reliance on ordering within a channel unless warranted Munindar P. Singh (NCSU) Service-Oriented Computing Spring 2014 22 / 29

slide-23
SLIDE 23

Specification Approaches State Diagrams

Outline

Specification Approaches Message Sequence Diagrams Protocols and Policies State Diagrams

Munindar P. Singh (NCSU) Service-Oriented Computing Spring 2014 23 / 29

slide-24
SLIDE 24

Specification Approaches 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 Spring 2014 24 / 29

slide-25
SLIDE 25

Specification Approaches State Diagrams

State Diagram Syntax

State 1 State 1 Substate 2 Substate 2 Substate 1.1 Substate 1.1 Substate 1.2 Substate 1.2

init event[guard] action

Munindar P. Singh (NCSU) Service-Oriented Computing Spring 2014 25 / 29

slide-26
SLIDE 26

Specification Approaches 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 Spring 2014 26 / 29

slide-27
SLIDE 27

Specification Approaches State Diagrams

Exercise: Diagram the Purchase Protocol with Return and Refund

Munindar P. Singh (NCSU) Service-Oriented Computing Spring 2014 27 / 29

slide-28
SLIDE 28

Specification Approaches State Diagrams

Exercise: Diagram Precedence, Occurrence, Exclusion

Across two messages, m1 and m2

Munindar P. Singh (NCSU) Service-Oriented Computing Spring 2014 28 / 29

slide-29
SLIDE 29

Specification Approaches 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 Spring 2014 29 / 29