Formal Modeling of RESTful Systems Using Finite-State...

63
Formal Modeling of RESTful Systems Formal Modeling of RESTful Systems Using Finite-State Machines Using Finite-State Machines Ivan Zuzak, Ivan Budiselic, Goran Delac School of Electrical Engineering and Computing, University of Zagreb, Zagreb, Croatia

Transcript of Formal Modeling of RESTful Systems Using Finite-State...

Page 1: Formal Modeling of RESTful Systems Using Finite-State …ivanzuzak.info/papers/2011_REST_slides.pdfJune 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 9/63

Formal Modeling of RESTful Systems Formal Modeling of RESTful Systems Using Finite-State MachinesUsing Finite-State Machines

Ivan Zuzak, Ivan Budiselic, Goran DelacSchool of Electrical Engineering and Computing, University of Zagreb, Zagreb, Croatia

Page 2: Formal Modeling of RESTful Systems Using Finite-State …ivanzuzak.info/papers/2011_REST_slides.pdfJune 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 9/63

June 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 2/63

Ivan Zuzak

● Ph.D student, University of Zagreb● Consumer Computing Laboratory

● http://www.geppeto.fer.hr ● Consumer programming methodology● Architectural styles, WWW infrastructure

● This Week in REST http://thisweekinrest.wordpress.com ● Bi-weekly blog on recent news about the REST style

Page 3: Formal Modeling of RESTful Systems Using Finite-State …ivanzuzak.info/papers/2011_REST_slides.pdfJune 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 9/63

June 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 3/63

Agenda

● Introduction● Motivation for modeling RESTful systems

● FSM Model of REST● REST introduction● eNFA introduction● Mapping REST to eNFA● Example Web application

● Closing Remarks● Future Work● Conclusion

63 slides?!?

Page 4: Formal Modeling of RESTful Systems Using Finite-State …ivanzuzak.info/papers/2011_REST_slides.pdfJune 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 9/63

June 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 4/63

Representational State Transfer (REST)

● Software architectural style● Abstract design principles

● Distributed hypermedia systems

● Scalability, simplicity, reliability ...

● Foundation of (a part of) the World Wide Web architecture

● HTTP, URI, HTML

Page 5: Formal Modeling of RESTful Systems Using Finite-State …ivanzuzak.info/papers/2011_REST_slides.pdfJune 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 9/63

June 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 5/63

Importance of Understanding REST

● Understanding and evolving the WWW● The WWW has grown in scale and complexity● Where are we now and where should we go?

● Applying REST to other domains● WWW is only one instance of REST● Can REST be applied to other domains? How?

● Engineering● Understanding is the basis for doing and doing well● Software frameworks, tools, …

Real-Time Web

RESTdiscuss

Page 6: Formal Modeling of RESTful Systems Using Finite-State …ivanzuzak.info/papers/2011_REST_slides.pdfJune 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 9/63

June 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 6/63

Problems with Understanding REST

● Lack of simple and operational formal models

● Existing models

● Semi-formal diagrams and natural language descriptions ● Formal models of hypermedia systems (not REST)● Models focused on the WWW (not REST)● Separate client and server● Static, non-operational● Misuse of terminology

Page 7: Formal Modeling of RESTful Systems Using Finite-State …ivanzuzak.info/papers/2011_REST_slides.pdfJune 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 9/63

June 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 7/63

Research Goal – Formalism for Modeling RESTful Systems

● Any RESTful system● The WWW is a guide, not a judge

● System as a whole ● Integrated view of both the client and server operation (the application)

● Operational● Both the static and dynamic view of operation

● Simple, understandable by researchers and engineers● “Use the least powerful language suitable for expressing information,

constraints or programs on the World Wide Web.”, 2006, W3C TAG

● Use established concepts and terminology● Dr. Fielding's thesis

Page 8: Formal Modeling of RESTful Systems Using Finite-State …ivanzuzak.info/papers/2011_REST_slides.pdfJune 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 9/63

June 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 8/63

REST Principles 101

Page 9: Formal Modeling of RESTful Systems Using Finite-State …ivanzuzak.info/papers/2011_REST_slides.pdfJune 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 9/63

June 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 9/63

REST Principles 101

● Layered client-server

Cacheable

Stateless

Code-on-demand

Uniform interface

Identification of resources

Manipulation of resources through representations

Self-descriptive messagesMethods, link types, media types, …

Hypermedia as the engine of application state

Links

User

agen

tIn

terme d

iariesO

rigin

server

Req Resp

Page 10: Formal Modeling of RESTful Systems Using Finite-State …ivanzuzak.info/papers/2011_REST_slides.pdfJune 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 9/63

June 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 10/63

REST Principles 101

● Layered client-server

● Cacheable

Stateless

Code-on-demand

Uniform interface

Identification of resources

Manipulation of resources through representations

Self-descriptive messagesMethods, link types, media types, …

Hypermedia as the engine of application state

Links

User

agen

tIn

terme d

iariesO

rigin

server

Cache

Cache

Cache

Req Resp

Page 11: Formal Modeling of RESTful Systems Using Finite-State …ivanzuzak.info/papers/2011_REST_slides.pdfJune 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 9/63

June 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 11/63

REST Principles 101

● Layered client-server

● Cacheable

● Stateless

Code-on-demand

Uniform interface

Identification of resources

Manipulation of resources through representations

Self-descriptive messagesMethods, link types, media types, …

Hypermedia as the engine of application state

Links

User

agen

tIn

terme d

iariesO

rigin

server

Cache

Cache

Cache

Appstate

Req Resp

Page 12: Formal Modeling of RESTful Systems Using Finite-State …ivanzuzak.info/papers/2011_REST_slides.pdfJune 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 9/63

June 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 12/63

REST Principles 101

● Layered client-server

● Cacheable

● Stateless

● Code-on-demand

Uniform interface

Identification of resources

Manipulation of resources through representations

Self-descriptive messagesMethods, link types, media types, …

Hypermedia as the engine of application state

Links

User

agen

tIn

terme d

iariesO

rigin

server

Cache

Cache

Cache

Appstate

Req Resp

COD engine

Page 13: Formal Modeling of RESTful Systems Using Finite-State …ivanzuzak.info/papers/2011_REST_slides.pdfJune 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 9/63

June 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 13/63

REST Principles 101

● Layered client-server

● Cacheable

● Stateless

● Code-on-demand

● Uniform interface● Identification of resources

● Manipulation of resources through representations

Self-descriptive messagesMethods, link types, media types, …

Hypermedia as the engine of application state

Links

User

agen

tIn

terme d

iariesO

rigin

server

Cache

Cache

Cache

Appstate

ResResRes

Req Resp

COD engine

Page 14: Formal Modeling of RESTful Systems Using Finite-State …ivanzuzak.info/papers/2011_REST_slides.pdfJune 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 9/63

June 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 14/63

REST Principles 101

● Layered client-server

● Cacheable

● Stateless

● Code-on-demand

● Uniform interface● Identification of resources

● Manipulation of resources through representations

● Self-descriptive messages

– Operations, media types, metadata …

Hypermedia as the engine of application state

Links

User

agen

tIn

terme d

iariesO

rigin

server

Cache

Cache

Cache

Appstate

ResResRes

Req Resp

MessageprocessorMessage

processor

Messageprocessor

Messageprocessor

COD engine

Page 15: Formal Modeling of RESTful Systems Using Finite-State …ivanzuzak.info/papers/2011_REST_slides.pdfJune 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 9/63

June 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 15/63

REST Principles 101

● Layered client-server

● Cacheable

● Stateless

● Code-on-demand

● Uniform interface● Identification of resources

● Manipulation of resources through representations

● Self-descriptive messages

– Operations, media types, metadata …

● Hypermedia as the engine of application state

– Links

User

agen

tIn

terme d

iariesO

rigin

server

Cache

Cache

Cache

Appstate

ResResRes

Req Resp

MessageprocessorMessage

processor

Messageprocessor

Messageprocessor

COD engine

Page 16: Formal Modeling of RESTful Systems Using Finite-State …ivanzuzak.info/papers/2011_REST_slides.pdfJune 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 9/63

June 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 16/63

Finite State Machines

● ε-NFA formalism

Nondeterministic

Epsilon transitions

States × (Inputs U ε) → P(State)

Page 17: Formal Modeling of RESTful Systems Using Finite-State …ivanzuzak.info/papers/2011_REST_slides.pdfJune 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 9/63

June 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 17/63

Finite State Machines

● ε-NFA formalism

● Finite state machine

Nondeterministic

Epsilon transitions

States × (Inputs U ε) → P(State)

S0

S1

S2

Page 18: Formal Modeling of RESTful Systems Using Finite-State …ivanzuzak.info/papers/2011_REST_slides.pdfJune 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 9/63

June 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 18/63

Finite State Machines

● ε-NFA formalism

● Finite state machine

Nondeterministic

Epsilon transitions

States × (Inputs U ε) → P(State)

S0

S1

S2

Page 19: Formal Modeling of RESTful Systems Using Finite-State …ivanzuzak.info/papers/2011_REST_slides.pdfJune 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 9/63

June 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 19/63

Finite State Machines

● ε-NFA formalism

● Finite state machine

Nondeterministic

Epsilon transitions

States × (Inputs U ε) → P(State)

S0

S1

S2

a

b

a

Page 20: Formal Modeling of RESTful Systems Using Finite-State …ivanzuzak.info/papers/2011_REST_slides.pdfJune 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 9/63

June 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 20/63

Finite State Machines

● ε-NFA formalism

● Finite state machine

Nondeterministic

Epsilon transitions

States × (Inputs U ε) → P(State)

S0

S1

S2S2

a

b

a

Page 21: Formal Modeling of RESTful Systems Using Finite-State …ivanzuzak.info/papers/2011_REST_slides.pdfJune 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 9/63

June 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 21/63

Finite State Machines

● ε-NFA formalism

● Finite state machine● Nondeterministic

Epsilon transitions

States × (Inputs U ε) → P(State)

S0

S1

S2S2

a

a

b

a

Page 22: Formal Modeling of RESTful Systems Using Finite-State …ivanzuzak.info/papers/2011_REST_slides.pdfJune 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 9/63

June 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 22/63

Finite State Machines

● ε-NFA formalism

● Finite state machine● Nondeterministic● Epsilon transitions

States × (Inputs U ε) → P(State)

S0

S1

S2S2

a

a

b

a

ε

Page 23: Formal Modeling of RESTful Systems Using Finite-State …ivanzuzak.info/papers/2011_REST_slides.pdfJune 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 9/63

June 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 23/63

Finite State Machines

● ε-NFA formalism

● Finite state machine● Nondeterministic● Epsilon transitions● Transition Function:

States × (Inputs U ε) → P(States)

S0

S1

S2S2

a

a

b

a

ε

Power set!

Page 24: Formal Modeling of RESTful Systems Using Finite-State …ivanzuzak.info/papers/2011_REST_slides.pdfJune 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 9/63

June 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 24/63

Finite State Machines

● ε-NFA formalism

● Finite state machine● Nondeterministic● Epsilon transitions● Transition Function:

States × (Inputs U ε) → P(States)

S0

S1

S2S2

● System level view

Nondeterministism

Transition function returns any state from a set, not known in advance which one

a

a

b

a

ε

InputSymbol

Generator

InputSymbol

Generator

CurrentState

CurrentState

TransitionFunction

TransitionFunction(1)

(2)

(2)

(3)

Power set!

Page 25: Formal Modeling of RESTful Systems Using Finite-State …ivanzuzak.info/papers/2011_REST_slides.pdfJune 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 9/63

June 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 25/63

Mapping REST to eNFA

● FSM = (States, Inputs, Initial, TransitionFunction, Accepting)

States = AppStates, AppStates P(Representations) − {}⊆Application state is a set of resource representations

Start state = initial application state at system startup

Representation with links to entry-points of know applications

Inputs (Requests × LinkTypes)⊆Requests (Operations×ResourceIDs×Representations)⊆

TransitionFunction : AppStates × ((Requests × LinkTypes) U ε) → P(AppStates)

Translation of input symbols into server requests

Processing of requests into responses (nondeterministic!)

Integration of response representations into the next application state

Code-on-demand transitions on the client

Accepting = SteadyStates, SteadyStates AppStates⊆In steady states, representations of all embedded resources are present in the application state

Page 26: Formal Modeling of RESTful Systems Using Finite-State …ivanzuzak.info/papers/2011_REST_slides.pdfJune 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 9/63

June 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 26/63

Mapping REST to eNFA

● FSM = (States, Inputs, Initial, TransitionFunction, Accepting)● States = AppStates, AppStates P(Representations) − {}⊆

– Application state is a subset of all possible representations of all resources

Start state = initial application state at system startup

Representation with links to entry-points of know applications

Inputs (Requests × LinkTypes)⊆Requests (Operations×ResourceIDs×Representations)⊆

TransitionFunction : AppStates × ((Requests × LinkTypes) U ε) → P(AppStates)

Translation of input symbols into server requests

Processing of requests into responses (nondeterministic!)

Integration of response representations into the next application state

Code-on-demand transitions on the client

Accepting = SteadyStates, SteadyStates AppStates⊆In steady states, representations of all embedded resources are present in the application state

Page 27: Formal Modeling of RESTful Systems Using Finite-State …ivanzuzak.info/papers/2011_REST_slides.pdfJune 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 9/63

June 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 27/63

Mapping REST to eNFA

● FSM = (States, Inputs, Initial, TransitionFunction, Accepting)● States = AppStates, AppStates P(Representations) − {}⊆

– Application state is a subset of all possible representations of all resources

● Initial = initial application state at system startup

– Representation with links to entry-points of known applications

Inputs (Requests × LinkTypes)⊆Requests (Operations×ResourceIDs×Representations)⊆

TransitionFunction : AppStates × ((Requests × LinkTypes) U ε) → P(AppStates)

Translation of input symbols into server requests

Processing of requests into responses (nondeterministic!)

Integration of response representations into the next application state

Code-on-demand transitions on the client

Accepting = SteadyStates, SteadyStates AppStates⊆In steady states, representations of all embedded resources are present in the application state

Page 28: Formal Modeling of RESTful Systems Using Finite-State …ivanzuzak.info/papers/2011_REST_slides.pdfJune 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 9/63

June 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 28/63

Mapping REST to eNFA

● FSM = (States, Inputs, Initial, TransitionFunction, Accepting)● States = AppStates, AppStates P(Representations) − {}⊆

– Application state is a subset of all possible representations of all resources

● Initial = initial application state at system startup

– Representation with links to entry-points of known applications

● Inputs (Requests × LinkTypes)⊆

– Requests (Operations×ResourceIDs×Representations)⊆

TransitionFunction : AppStates × ((Requests × LinkTypes) U ε) → P(AppStates)

Translation of input symbols into server requests

Processing of requests into responses (nondeterministic!)

Integration of response representations into the next application state

Code-on-demand transitions on the client

Accepting = SteadyStates, SteadyStates AppStates⊆In steady states, representations of all embedded resources are present in the application state

Page 29: Formal Modeling of RESTful Systems Using Finite-State …ivanzuzak.info/papers/2011_REST_slides.pdfJune 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 9/63

June 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 29/63

Importance of Link Types

● Different state transition semantics

GET /photo.jpg HTTP/1.1

HTTP/1.1 200 OK

● Navigation to image (<a>) or embedding in a Web page (<img>)?

Page 30: Formal Modeling of RESTful Systems Using Finite-State …ivanzuzak.info/papers/2011_REST_slides.pdfJune 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 9/63

June 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 30/63

Mapping REST to eNFA

● FSM = (States, Inputs, Initial, TransitionFunction, Accepting)● States = AppStates, AppStates P(Representations) − {}⊆

– Application state is a subset of all possible representations of all resources

● Initial = initial application state at system startup

– Representation with links to entry-points of known applications

● Inputs (Requests × LinkTypes)⊆

– Requests (Operations×ResourceIDs×Representations)⊆

● TransitionFunction : AppStates × ((Requests × LinkTypes) U ε) → P(AppStates)

– Translation of input symbols into server requests

– Processing of requests into responses (nondeterministic!)

– Integration of response representations into the next application state

– Code-on-demand transitions on the client

Accepting = SteadyStates, SteadyStates AppStates⊆In steady states, representations of all embedded resources are present in the application state

Page 31: Formal Modeling of RESTful Systems Using Finite-State …ivanzuzak.info/papers/2011_REST_slides.pdfJune 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 9/63

June 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 31/63

Mapping REST to eNFA

● FSM = (States, Inputs, Initial, TransitionFunction, Accepting)● States = AppStates, AppStates P(Representations) − {}⊆

– Application state is a subset of all possible representations of all resources

● Initial = initial application state at system startup

– Representation with links to entry-points of known applications

● Inputs (Requests × LinkTypes)⊆

– Requests (Operations×ResourceIDs×Representations)⊆

● TransitionFunction : AppStates × ((Requests × LinkTypes) U ε) → P(AppStates)

– Translation of input symbols into server requests

– Processing of requests into responses (nondeterministic!)

– Integration of response representations into the next application state

– Code-on-demand transitions on the client

● Accepting = SteadyStates, SteadyStates AppStates⊆

– In steady states, representations of all embedded resources are present in the application state

Page 32: Formal Modeling of RESTful Systems Using Finite-State …ivanzuzak.info/papers/2011_REST_slides.pdfJune 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 9/63

June 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 32/63

Mapping REST to eNFA

Input Symbol GeneratorInput Symbol Generator

Current StateCurrent State

Transition FunctionTransition Function

Page 33: Formal Modeling of RESTful Systems Using Finite-State …ivanzuzak.info/papers/2011_REST_slides.pdfJune 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 9/63

June 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 33/63

Mapping REST to eNFA

Input Symbol GeneratorInput Symbol Generator

Current StateCurrent State

Transition FunctionTransition Function

REST client

RE

ST

server

Page 34: Formal Modeling of RESTful Systems Using Finite-State …ivanzuzak.info/papers/2011_REST_slides.pdfJune 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 9/63

June 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 34/63

Mapping REST to eNFA

Input Symbol GeneratorInput Symbol Generator

Current StateCurrent State

Transition FunctionTransition Function

ApplicationState

REST client

RE

ST

server

Page 35: Formal Modeling of RESTful Systems Using Finite-State …ivanzuzak.info/papers/2011_REST_slides.pdfJune 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 9/63

June 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 35/63

Mapping REST to eNFA

Input Symbol GeneratorInput Symbol Generator

Current StateCurrent State

Transition FunctionTransition Function

Med

ia T

ype

Pro

cess

or

ApplicationState

(1)

REST client

RE

ST

server

Page 36: Formal Modeling of RESTful Systems Using Finite-State …ivanzuzak.info/papers/2011_REST_slides.pdfJune 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 9/63

June 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 36/63

Mapping REST to eNFA

Input Symbol GeneratorInput Symbol Generator

Current StateCurrent State

Transition FunctionTransition Function

Med

ia T

ype

Pro

cess

or

Application-levelLogic

ApplicationState

Hypermedia-level Logic

(1)

(2)

REST client

RE

ST

server

Page 37: Formal Modeling of RESTful Systems Using Finite-State …ivanzuzak.info/papers/2011_REST_slides.pdfJune 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 9/63

June 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 37/63

Mapping REST to eNFA

Input Symbol GeneratorInput Symbol Generator

Current StateCurrent State

Transition FunctionTransition Function

RequestPreprocessor

Med

ia T

ype

Pro

cess

or

Application-levelLogic

ApplicationState

Hypermedia-level Logic

(1)

(2)

(3)

REST client

RE

ST

server

Page 38: Formal Modeling of RESTful Systems Using Finite-State …ivanzuzak.info/papers/2011_REST_slides.pdfJune 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 9/63

June 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 38/63

Mapping REST to eNFA

Input Symbol GeneratorInput Symbol Generator

Current StateCurrent State

Transition FunctionTransition Function

RequestPreprocessor

RequestProcessor

Med

ia T

ype

Pro

cess

or

Application-levelLogic

ApplicationState

Hypermedia-level Logic

(1)

(2)

(3)

(4)

REST client

RE

ST

server

Page 39: Formal Modeling of RESTful Systems Using Finite-State …ivanzuzak.info/papers/2011_REST_slides.pdfJune 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 9/63

June 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 39/63

Mapping REST to eNFA

Input Symbol GeneratorInput Symbol Generator

Current StateCurrent State

Transition FunctionTransition Function

StateIntegrator

RequestPreprocessor

RequestProcessor

Med

ia T

ype

Pro

cess

or

Application-levelLogic

ApplicationState

Hypermedia-level Logic

(1)

(2)

(3)

(4)

(5)

REST client

RE

ST

server

Page 40: Formal Modeling of RESTful Systems Using Finite-State …ivanzuzak.info/papers/2011_REST_slides.pdfJune 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 9/63

June 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 40/63

Mapping REST to eNFA

Input Symbol GeneratorInput Symbol Generator

Current StateCurrent State

Transition FunctionTransition Function

StateIntegrator

RequestPreprocessor

RequestProcessor

Med

ia T

ype

Pro

cess

or

Application-levelLogic

ApplicationState

Hypermedia-level Logic

(1)

(2)

(3)

(4)

(5)

(6)

REST client

RE

ST

server

Page 41: Formal Modeling of RESTful Systems Using Finite-State …ivanzuzak.info/papers/2011_REST_slides.pdfJune 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 9/63

June 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 41/63

Mapping REST to eNFA

Input Symbol GeneratorInput Symbol Generator

Current StateCurrent State

Transition FunctionTransition Function

StateIntegrator

RequestPreprocessor

Code-on-demand Engine

RequestProcessor

Med

ia T

ype

Pro

cess

or

Application-levelLogic

ApplicationState

Hypermedia-level Logic

(1)

(2)

(3)

(4)

(5)

(6)

(7)

(7)

REST client

RE

ST

server

Page 42: Formal Modeling of RESTful Systems Using Finite-State …ivanzuzak.info/papers/2011_REST_slides.pdfJune 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 9/63

June 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 42/63

Mapping REST to eNFA

Input Symbol GeneratorInput Symbol Generator

Current StateCurrent State

Transition FunctionTransition Function

StateIntegrator

RequestPreprocessor

Code-on-demand Engine

RequestProcessor

Med

ia T

ype

Pro

cess

or

Application-levelLogic

ApplicationState

Hypermedia-level Logic

(1)

(2)

(3)

(4)

(5)

(6)

(7)

(7)

(8)

REST client

RE

ST

server

Page 43: Formal Modeling of RESTful Systems Using Finite-State …ivanzuzak.info/papers/2011_REST_slides.pdfJune 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 9/63

June 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 43/63

Example: Weather Forecast Web Application

Welcome!

Details Main

/main /details

<A>

<A>

Page 44: Formal Modeling of RESTful Systems Using Finite-State …ivanzuzak.info/papers/2011_REST_slides.pdfJune 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 9/63

June 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 44/63

Example: Weather Forecast Web Application

Welcome!

Details Main

/main /details

// script changes// color of <a> tags

/script

<SCRIPT>

<A>

<A>

Page 45: Formal Modeling of RESTful Systems Using Finite-State …ivanzuzak.info/papers/2011_REST_slides.pdfJune 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 9/63

June 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 45/63

Example: Weather Forecast Web Application

Welcome!

Details Main

/main /details

// script changes// color of <a> tags {25, 15}

Temp: 25C

/temp/script

<SCRIPT>

XHR

<A>

<A>

Page 46: Formal Modeling of RESTful Systems Using Finite-State …ivanzuzak.info/papers/2011_REST_slides.pdfJune 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 9/63

June 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 46/63

Example: Weather Forecast Web Application

Welcome!

Details Main

/main /details

// script changes// color of <a> tags {25, 15}

Temp: 25C

/sunny

/cloudy

/temp/script

<IMG>

<SCRIPT>

XHR

<A>

<A>

Page 47: Formal Modeling of RESTful Systems Using Finite-State …ivanzuzak.info/papers/2011_REST_slides.pdfJune 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 9/63

June 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 47/63

Example: Weather Forecast Web Application

S20

Initial State

Page 48: Formal Modeling of RESTful Systems Using Finite-State …ivanzuzak.info/papers/2011_REST_slides.pdfJune 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 9/63

June 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 48/63

Example: Weather Forecast Web Application

S20 1

Main page

aa

Initial State

Page 49: Formal Modeling of RESTful Systems Using Finite-State …ivanzuzak.info/papers/2011_REST_slides.pdfJune 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 9/63

June 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 49/63

Example: Weather Forecast Web Application

S20 1

Main pageScript fetch and color changes

S22

S23

a

b

a

ε

ε

Initial State

Page 50: Formal Modeling of RESTful Systems Using Finite-State …ivanzuzak.info/papers/2011_REST_slides.pdfJune 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 9/63

June 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 50/63

Example: Weather Forecast Web Application

S20 1

4

5

Main pageScript fetch and color changes Details page

S22

S23

a

b

c

c

c

c

a

ε

ε

Initial State

Sunny w

eatherC

loudy weathe r

Page 51: Formal Modeling of RESTful Systems Using Finite-State …ivanzuzak.info/papers/2011_REST_slides.pdfJune 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 9/63

June 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 51/63

Example: Weather Forecast Web Application

S20 1

4

5

Main pageScript fetch and color changes Details page Weather image

S22

S23

S26

S27

a

b

c d

ec

c

c

a

ε

ε

Initial State

Sunny w

eatherC

loudy weathe r

Page 52: Formal Modeling of RESTful Systems Using Finite-State …ivanzuzak.info/papers/2011_REST_slides.pdfJune 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 9/63

June 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 52/63

Example: Weather Forecast Web Application

S20 1

4

5

Main pageScript fetch and color changes Details page Weather image

Temperature fetches and changes

S22

S23

S26

S27

S28 S212

S29 S213

S210 S214

S211 S215

a

b

c d

ec

c

c

a

f

f f

f

ε

ε

ε

ε

ε

ε

Initial State

Sunny w

eatherC

loudy weathe r

Page 53: Formal Modeling of RESTful Systems Using Finite-State …ivanzuzak.info/papers/2011_REST_slides.pdfJune 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 9/63

June 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 53/63

Example: Weather Forecast Web Application

S20 1

4

5

Main pageScript fetch and color changes Details page Weather image

Temperature fetches and changes

S22

S23

S26

S27

S28 S212

S29 S213

S210 S214

S211 S215

a

b

c d

ec

c

c

a a

a

a

f

f f

f

ε

ε

ε

ε

ε

ε

Initial State

Sunny w

eatherC

loudy weathe r

Page 54: Formal Modeling of RESTful Systems Using Finite-State …ivanzuzak.info/papers/2011_REST_slides.pdfJune 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 9/63

June 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 54/63

Example: Weather Forecast Web Application

ASmain

= [(metadata : “...”, data : “/main contents”),

(metadata : “...”, data : “/script contents”)]

IStoDetails

= (request : (method : “GET ”, resourceId : “/details”,

representation : “”), linkType : “<a>”)

δ(ASmain

, IStoDetails

) = {ASdetailsCloudy

, ASdetailsSunny

}

ASdetailsCloudy

= [(metadata : [mediaType : “text/html”],

data : “/details content with link to /cloudy”)] AS

detailsSunny = [(metadata : [mediaType : “text/html”],

data : “/details content with link to /sunny”)]

δ(ASdetailsCloudy

, IStoDetails

) = {}

Fully loaded/main page

Page 55: Formal Modeling of RESTful Systems Using Finite-State …ivanzuzak.info/papers/2011_REST_slides.pdfJune 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 9/63

June 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 55/63

Example: Weather Forecast Web Application

ASmain

= [(metadata : “...”, data : “/main contents”),

(metadata : “...”, data : “/script contents”)]

IStoDetails

= (request : (method : “GET ”, resourceId : “/details”,

representation : “”), linkType : “<a>”)

δ(ASmain

, IStoDetails

) = {ASdetailsCloudy

, ASdetailsSunny

}

ASdetailsCloudy

= [(metadata : [mediaType : “text/html”],

data : “/details content with link to /cloudy”)] AS

detailsSunny = [(metadata : [mediaType : “text/html”],

data : “/details content with link to /sunny”)]

δ(ASdetailsCloudy

, IStoDetails

) = {}

Fully loaded/main page

/details page request

Page 56: Formal Modeling of RESTful Systems Using Finite-State …ivanzuzak.info/papers/2011_REST_slides.pdfJune 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 9/63

June 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 56/63

Example: Weather Forecast Web Application

ASmain

= [(metadata : “...”, data : “/main contents”),

(metadata : “...”, data : “/script contents”)]

IStoDetails

= (request : (method : “GET ”, resourceId : “/details”,

representation : “”), linkType : “<a>”)

δ(ASmain

, IStoDetails

) = {ASdetailsCloudy

, ASdetailsSunny

}

ASdetailsCloudy

= [(metadata : [mediaType : “text/html”],

data : “/details content with link to /cloudy”)] AS

detailsSunny = [(metadata : [mediaType : “text/html”],

data : “/details content with link to /sunny”)]

δ(ASdetailsCloudy

, IStoDetails

) = {}

Fully loaded/main page

/details page request

/details transition

Page 57: Formal Modeling of RESTful Systems Using Finite-State …ivanzuzak.info/papers/2011_REST_slides.pdfJune 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 9/63

June 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 57/63

Example: Weather Forecast Web Application

ASmain

= [(metadata : “...”, data : “/main contents”),

(metadata : “...”, data : “/script contents”)]

IStoDetails

= (request : (method : “GET ”, resourceId : “/details”,

representation : “”), linkType : “<a>”)

δ(ASmain

, IStoDetails

) = {ASdetailsCloudy

, ASdetailsSunny

}

ASdetailsCloudy

= [(metadata : [mediaType : “text/html”],

data : “/details content with link to /cloudy”)] AS

detailsSunny = [(metadata : [mediaType : “text/html”],

data : “/details content with link to /sunny”)]

δ(ASdetailsCloudy

, IStoDetails

) = {}

Fully loaded/main page

/details page request

/details transition

Partially loaded /details page

Page 58: Formal Modeling of RESTful Systems Using Finite-State …ivanzuzak.info/papers/2011_REST_slides.pdfJune 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 9/63

June 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 58/63

Future Work

● Reduce state explosion problem● Aggregating similar states into a single state

– States are similar if they have the same representations with the same links, but data may be different

Apply the formalism to more systems

Web 1.0 documents vs Web 2.0 applications

Web APIs vs Web applications

Unaddressed priciples of RESTful systems

Layered and cacheable constraints

Software framework for development of RESTful systems

Page 59: Formal Modeling of RESTful Systems Using Finite-State …ivanzuzak.info/papers/2011_REST_slides.pdfJune 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 9/63

June 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 59/63

Future Work

● Reduce state explosion problem● Aggregating similar states into a single state

– States are similar if they have the same representations with the same links, but data may be different

● Apply the formalism to more systems● Web 1.0 documents vs Web 2.0 applications● Web APIs vs Web applications

Unaddressed priciples of RESTful systems

Layered and cacheable constraints

Software framework for development of RESTful systems

Page 60: Formal Modeling of RESTful Systems Using Finite-State …ivanzuzak.info/papers/2011_REST_slides.pdfJune 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 9/63

June 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 60/63

Future Work

● Reduce state explosion problem● Aggregating similar states into a single state

– States are similar if they have the same representations with the same links, but data may be different

● Apply the formalism to more systems● Web 1.0 documents vs Web 2.0 applications● Web APIs vs Web applications

● Unaddressed priciples of RESTful systems● Layered and cacheable constraints

Software framework for development of RESTful systems

Page 61: Formal Modeling of RESTful Systems Using Finite-State …ivanzuzak.info/papers/2011_REST_slides.pdfJune 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 9/63

June 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 61/63

Future Work

● Reduce state explosion problem● Aggregating similar states into a single state

– States are similar if they have the same representations with the same links, but data may be different

● Apply the formalism to more systems● Web 1.0 documents vs Web 2.0 applications● Web APIs vs Web applications

● Unaddressed priciples of RESTful systems● Layered and cacheable constraints

● Software framework for development of RESTful systems

Page 62: Formal Modeling of RESTful Systems Using Finite-State …ivanzuzak.info/papers/2011_REST_slides.pdfJune 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 9/63

June 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 62/63

Conclusion

● Understanding REST is important● Formal models, systematization, terminology

● eNFA formalism ● Captures “~98%” of REST's principles● Simple, generic, operational, system-wide

● Exciting directions for future research!● Annonymous reviewer: “A model by itself has little

value unless it is used for some purpose.”

Page 63: Formal Modeling of RESTful Systems Using Finite-State …ivanzuzak.info/papers/2011_REST_slides.pdfJune 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 9/63

June 22, 2011 Formal Modeling of RESTful Systems Using Finite-State Machines 63/63

Thank you!Contact:

[email protected]

http://twitter.com/izuzak