SlideShare a Scribd company logo
Type-Safe Evolution of 

Web Services
João Campinhos, João Costa Seco, Jácome Cunha

NOVA LINCS, Universidade NOVA de Lisboa, Portugal
j.campinhos@campus.fct.unl.pt, joao.seco@fct.unl.pt,
jacome@fct.unl.pt
Second International Workshop on Variability and Complexity in Software Design
VACE @ ICSE 2017
27 May, 2017 - Buenos Aires, Argentina
Problem
• Mobile/Web apps based on micro or web services have
had significant growth (smartphones explosion)
• Client and server are loosely coupled
• Using such kind of interfaces provides almost no
guarantees to the (client) developer in terms of evolution
• Changes to service interfaces can be introduced at any
moment, causing the clients to fail
• All of us now this evolution happens all the time
2
An Example of a Web Service for Users - v1.0
server implementation – version 1.0
user() => { name: “John Doe” }
client implementation – version 1.0
user().name.trim()
3
Server Evolution
server implementation – version 2.0
user() => { name:{ first: “John”,
last: “Doe” }}
client implementation – version 1.0
user().name.trim()
4
Clients Need to Go Along…
server implementation – version 2.0
user() => { name:{ first: “John”,
last: "Doe" }}
client implementation – version 2.0
user().name.first + “ “ + user().name.last
5
Several Issues
• It is probably not feasible to update all clients
to the latest version at the same time
• It is probably not possible to keep all service
interfaces and maintain them all
• If the client moves from version A to version B,
then all the code needs to move (not
incremental)
6
How can we help server and client
developers cope with evolution?
?
7
Towards a Solution
•Coexistence Principle
•Compatibility Principle
•Safety Principle
•Modularity Principle
8
Coexistence Principle
• Coexistence Principle: to make all the existing
versions available as a complete application, as a
unique code base
• Making use of annotations in the client requests and
in the server code to identify which version(s) to use
to attend a request
• Both versions 1.0 and 2.0 of the server should coexist
at the same time and should be usable by a client,
both at the same time
9
Coexistence Principle
{
(version = ’1.0’) => {
var currentuser = {name: “John Doe”};
function user() : {name: string}
{
return currentuser;
}
}
(version = ’2.0’) => {
var currentuser = {name: {first:”John”, last: ”Doe”}};
function user() : {name: {first: string, last: string}}
{

return currentuser;
}
}
} 10
Reuse
•The coexistence of versions only makes sense if
it is possible to reuse code across versions
•We introduce a language construct that allows
the annotation of an expression e with a
version v where it should be evaluated



(version = ‘v’) => e
11
12
(version = ’1.0’) => {
var currentuser = {name: “John Doe”};
function user() : {name: string}
{
return (version ‘2.0’) => { name: user().first + “ “ + user().last };
}
}
(version = ’2.0’) => {
var currentuser = {name: {first:”John”, last: ”Doe”}};
function user() : {name: {first: string, last: string}}
{

return currentuser;
}
}
Small Change to v2.0
…
(version = ’2.0’) => {
var currentuser = {name: {first:”John”, last: ”Doe”}};
function user() : {name: {first: string, last: string}}
{

return currentuser;
}
}
(version = ’2.1’) => {
function user(): {name:{first: string, last: string}, age:int}
{
return (version = ’2.0’) => {user(), age: 42};
}
} 13
14
• In this case, the type of the response in
version 2.1 is a subtype of the response
in version 2.0
• In many cases, it is still possible for
clients to interact with the new version
• This makes it possible for version 2.1 to
be used whenever version 2.0 is
requested
Compatibility Principle
• Compatibility Principle: a system should serve its
clients with (type) compatible versions at all times
• Our solution is to use a relation on versions that
embeds the notion of compatibility between
versions
• We introduce version patterns which define the
base version for searching the correct
implementation
15
16
…
(version = ’2.0’) => {
var currentuser = {name: {first:”John”, last: ”Doe”}};
function user() : {name: {first: string, last: string}}
{

return currentuser;
}
}
(version = ’2.1’) => {
function user(): {name:{first: string, last: string}, age:int}
{
return (version = ’2.0’) => {user(), age: 42};
return (version = ’2.*’) => {user(), age: 42};
}
}
An Example of a Relation
17
1.0
2.0
2.1
1.0-A
user():{name:string}
user():{name:{first: string,
last: string}}
user():{name:{first: string,
last: string},
age:int}
strictfree
subtyping
Compatibility Modes
•Strict: all the changes from one version to
another preserve the types of all declared
identifiers (functions and variables)
•Subtyping: all changes from one version to
another follow the subtype relation
•Free: does not constraint the changes on the
type signatures, as to allow the developer to
arbitrarily change the source code
18
An Example of a Relation
19
1.0
2.0
2.1
1.0-A
user():{name:string}
user():{name:{first: string,
last: string}}
user():{name:{first: string,
last: string},
age:int}
strictfree
subtyping
Back to the Client Code - Subtyping Mode
second client implementation – version 2.0
(version = ’2.*’) => { user().name.first }
• Client code maybe still be in version 2.0, but if
it requests the most updated version of the
service, version 2.1 will be served
20
Type Checker and Dispatching System
• The static type checker considers all versions
and the compatibility modes between them to
typecheck the code base
• The runtime dispatching system also takes into
consideration the relation between the
different version to serve the appropriate one
21
Safety Principle
•A third (and more general) principle becomes
essential to reach a sound solution
•Safety Principle: all possible entry points of
the system should be type safe, in all versions,
and considering all possible version
redirections given by the version compatibility
relation
22
Modularity Principle
•Modularity Principle: the static verification of
code and the dynamic dispatching of requests
and execution should be decoupled from the
actual definition of what a version is and how
versions relate
•This implies the relation is defined by the
server developer to relate any versions using
any compatibility mode
23
Open-Source Prototype Implementation
24
Annotated
JavaScript
Code
Syntactic
Analysis
Version
Type
Checker
Flow Transpiler
JavaScript
Code
Router
Request
(version,
mode)
Function
Relation
AST
http://github.com/niverso
Babel Ours
Flow Syntax
Type Checker
Conclusions & Future Work
•We introduced a new programming model to develop and
evolve software with multiple versions at the same time
•It copes with evolution using version compatibility modes
•Our approach is flexible as it is parametric on any version
control system developers may use
•The type system we developed can typecheck programs
with several versions at the same time
•The dispatching function dynamically decides what is the
best version of a particular component for each request
25
Conclusions & Future Work
•As a proof of concept we have implemented our
programming model as a prototype using the Flow
typechecker and JavaScript
•As future work, we want to formally certify the soundness
of the approach
•Also, experimental work must be performed with larger
case-studies
•We would also like to develop an IDE with this
programming model built-in
26

More Related Content

Similar to Type-Safe Evolution of 
Web Services

Foundational Design Patterns for Multi-Purpose Applications
Foundational Design Patterns for Multi-Purpose ApplicationsFoundational Design Patterns for Multi-Purpose Applications
Foundational Design Patterns for Multi-Purpose ApplicationsChing-Hwa Yu
 
Wading through treacle? Escape the integration syrup with contract tests
Wading through treacle? Escape the integration syrup with contract testsWading through treacle? Escape the integration syrup with contract tests
Wading through treacle? Escape the integration syrup with contract tests
Stefan Smith
 
CI/CD Pipeline with Docker
CI/CD Pipeline with DockerCI/CD Pipeline with Docker
CI/CD Pipeline with Docker
kushalsingh007
 
Vijay Oscon
Vijay OsconVijay Oscon
Vijay Oscon
vijayrvr
 
Decomposing the Monolith (Riga Dev Days 2019)
Decomposing the Monolith (Riga Dev Days 2019)Decomposing the Monolith (Riga Dev Days 2019)
Decomposing the Monolith (Riga Dev Days 2019)
Dennis Doomen
 
.NET Innovations and Improvements
.NET Innovations and Improvements.NET Innovations and Improvements
.NET Innovations and Improvements
Jeff Chu
 
Mantis Code Deployment Process
Mantis Code Deployment ProcessMantis Code Deployment Process
Mantis Code Deployment Process
Jen Wei Lee
 
Micro service architecture
Micro service architectureMicro service architecture
Micro service architecture
uEngine Solutions
 
DevOps.pptx
DevOps.pptxDevOps.pptx
DevOps.pptx
EswarVineet
 
Building a CI/CD Pipeline for PHP apps
Building a CI/CD Pipeline for PHP appsBuilding a CI/CD Pipeline for PHP apps
Building a CI/CD Pipeline for PHP apps
Juan Manuel Torres
 
Chat application through client server management system project.pdf
Chat application through client server management system project.pdfChat application through client server management system project.pdf
Chat application through client server management system project.pdf
Kamal Acharya
 
Loadrunner interview questions and answers
Loadrunner interview questions and answersLoadrunner interview questions and answers
Loadrunner interview questions and answers
Garuda Trainings
 
16 implementation techniques
16 implementation techniques16 implementation techniques
16 implementation techniquesMajong DevJfu
 
Altitude NY 2018: 132 websites, 1 service: Your local news runs on Fastly
Altitude NY 2018: 132 websites, 1 service: Your local news runs on FastlyAltitude NY 2018: 132 websites, 1 service: Your local news runs on Fastly
Altitude NY 2018: 132 websites, 1 service: Your local news runs on Fastly
Fastly
 
Onine exam 1
Onine exam 1Onine exam 1
Moving Applications into Azure Kubernetes
Moving Applications into Azure KubernetesMoving Applications into Azure Kubernetes
Moving Applications into Azure Kubernetes
Hussein Salman
 
Revealing C# 5
Revealing C# 5Revealing C# 5
Revealing C# 5
Praveen Prajapati
 
video conference (peer to peer)
video conference (peer to peer)video conference (peer to peer)
video conference (peer to peer)
mohamed amr
 
Keynote VST2020 (Workshop on Validation, Analysis and Evolution of Software ...
Keynote VST2020 (Workshop on  Validation, Analysis and Evolution of Software ...Keynote VST2020 (Workshop on  Validation, Analysis and Evolution of Software ...
Keynote VST2020 (Workshop on Validation, Analysis and Evolution of Software ...
University of Antwerp
 
InterConnect 2016 Java EE 7 Overview (PEJ-5296)
InterConnect 2016 Java EE 7 Overview (PEJ-5296)InterConnect 2016 Java EE 7 Overview (PEJ-5296)
InterConnect 2016 Java EE 7 Overview (PEJ-5296)
Kevin Sutter
 

Similar to Type-Safe Evolution of 
Web Services (20)

Foundational Design Patterns for Multi-Purpose Applications
Foundational Design Patterns for Multi-Purpose ApplicationsFoundational Design Patterns for Multi-Purpose Applications
Foundational Design Patterns for Multi-Purpose Applications
 
Wading through treacle? Escape the integration syrup with contract tests
Wading through treacle? Escape the integration syrup with contract testsWading through treacle? Escape the integration syrup with contract tests
Wading through treacle? Escape the integration syrup with contract tests
 
CI/CD Pipeline with Docker
CI/CD Pipeline with DockerCI/CD Pipeline with Docker
CI/CD Pipeline with Docker
 
Vijay Oscon
Vijay OsconVijay Oscon
Vijay Oscon
 
Decomposing the Monolith (Riga Dev Days 2019)
Decomposing the Monolith (Riga Dev Days 2019)Decomposing the Monolith (Riga Dev Days 2019)
Decomposing the Monolith (Riga Dev Days 2019)
 
.NET Innovations and Improvements
.NET Innovations and Improvements.NET Innovations and Improvements
.NET Innovations and Improvements
 
Mantis Code Deployment Process
Mantis Code Deployment ProcessMantis Code Deployment Process
Mantis Code Deployment Process
 
Micro service architecture
Micro service architectureMicro service architecture
Micro service architecture
 
DevOps.pptx
DevOps.pptxDevOps.pptx
DevOps.pptx
 
Building a CI/CD Pipeline for PHP apps
Building a CI/CD Pipeline for PHP appsBuilding a CI/CD Pipeline for PHP apps
Building a CI/CD Pipeline for PHP apps
 
Chat application through client server management system project.pdf
Chat application through client server management system project.pdfChat application through client server management system project.pdf
Chat application through client server management system project.pdf
 
Loadrunner interview questions and answers
Loadrunner interview questions and answersLoadrunner interview questions and answers
Loadrunner interview questions and answers
 
16 implementation techniques
16 implementation techniques16 implementation techniques
16 implementation techniques
 
Altitude NY 2018: 132 websites, 1 service: Your local news runs on Fastly
Altitude NY 2018: 132 websites, 1 service: Your local news runs on FastlyAltitude NY 2018: 132 websites, 1 service: Your local news runs on Fastly
Altitude NY 2018: 132 websites, 1 service: Your local news runs on Fastly
 
Onine exam 1
Onine exam 1Onine exam 1
Onine exam 1
 
Moving Applications into Azure Kubernetes
Moving Applications into Azure KubernetesMoving Applications into Azure Kubernetes
Moving Applications into Azure Kubernetes
 
Revealing C# 5
Revealing C# 5Revealing C# 5
Revealing C# 5
 
video conference (peer to peer)
video conference (peer to peer)video conference (peer to peer)
video conference (peer to peer)
 
Keynote VST2020 (Workshop on Validation, Analysis and Evolution of Software ...
Keynote VST2020 (Workshop on  Validation, Analysis and Evolution of Software ...Keynote VST2020 (Workshop on  Validation, Analysis and Evolution of Software ...
Keynote VST2020 (Workshop on Validation, Analysis and Evolution of Software ...
 
InterConnect 2016 Java EE 7 Overview (PEJ-5296)
InterConnect 2016 Java EE 7 Overview (PEJ-5296)InterConnect 2016 Java EE 7 Overview (PEJ-5296)
InterConnect 2016 Java EE 7 Overview (PEJ-5296)
 

Recently uploaded

The use of Nauplii and metanauplii artemia in aquaculture (brine shrimp).pptx
The use of Nauplii and metanauplii artemia in aquaculture (brine shrimp).pptxThe use of Nauplii and metanauplii artemia in aquaculture (brine shrimp).pptx
The use of Nauplii and metanauplii artemia in aquaculture (brine shrimp).pptx
MAGOTI ERNEST
 
3D Hybrid PIC simulation of the plasma expansion (ISSS-14)
3D Hybrid PIC simulation of the plasma expansion (ISSS-14)3D Hybrid PIC simulation of the plasma expansion (ISSS-14)
3D Hybrid PIC simulation of the plasma expansion (ISSS-14)
David Osipyan
 
DMARDs Pharmacolgy Pharm D 5th Semester.pdf
DMARDs Pharmacolgy Pharm D 5th Semester.pdfDMARDs Pharmacolgy Pharm D 5th Semester.pdf
DMARDs Pharmacolgy Pharm D 5th Semester.pdf
fafyfskhan251kmf
 
mô tả các thí nghiệm về đánh giá tác động dòng khí hóa sau đốt
mô tả các thí nghiệm về đánh giá tác động dòng khí hóa sau đốtmô tả các thí nghiệm về đánh giá tác động dòng khí hóa sau đốt
mô tả các thí nghiệm về đánh giá tác động dòng khí hóa sau đốt
HongcNguyn6
 
Leaf Initiation, Growth and Differentiation.pdf
Leaf Initiation, Growth and Differentiation.pdfLeaf Initiation, Growth and Differentiation.pdf
Leaf Initiation, Growth and Differentiation.pdf
RenuJangid3
 
Observation of Io’s Resurfacing via Plume Deposition Using Ground-based Adapt...
Observation of Io’s Resurfacing via Plume Deposition Using Ground-based Adapt...Observation of Io’s Resurfacing via Plume Deposition Using Ground-based Adapt...
Observation of Io’s Resurfacing via Plume Deposition Using Ground-based Adapt...
Sérgio Sacani
 
Deep Software Variability and Frictionless Reproducibility
Deep Software Variability and Frictionless ReproducibilityDeep Software Variability and Frictionless Reproducibility
Deep Software Variability and Frictionless Reproducibility
University of Rennes, INSA Rennes, Inria/IRISA, CNRS
 
Travis Hills' Endeavors in Minnesota: Fostering Environmental and Economic Pr...
Travis Hills' Endeavors in Minnesota: Fostering Environmental and Economic Pr...Travis Hills' Endeavors in Minnesota: Fostering Environmental and Economic Pr...
Travis Hills' Endeavors in Minnesota: Fostering Environmental and Economic Pr...
Travis Hills MN
 
Phenomics assisted breeding in crop improvement
Phenomics assisted breeding in crop improvementPhenomics assisted breeding in crop improvement
Phenomics assisted breeding in crop improvement
IshaGoswami9
 
Nucleic Acid-its structural and functional complexity.
Nucleic Acid-its structural and functional complexity.Nucleic Acid-its structural and functional complexity.
Nucleic Acid-its structural and functional complexity.
Nistarini College, Purulia (W.B) India
 
ANAMOLOUS SECONDARY GROWTH IN DICOT ROOTS.pptx
ANAMOLOUS SECONDARY GROWTH IN DICOT ROOTS.pptxANAMOLOUS SECONDARY GROWTH IN DICOT ROOTS.pptx
ANAMOLOUS SECONDARY GROWTH IN DICOT ROOTS.pptx
RASHMI M G
 
Eukaryotic Transcription Presentation.pptx
Eukaryotic Transcription Presentation.pptxEukaryotic Transcription Presentation.pptx
Eukaryotic Transcription Presentation.pptx
RitabrataSarkar3
 
Unveiling the Energy Potential of Marshmallow Deposits.pdf
Unveiling the Energy Potential of Marshmallow Deposits.pdfUnveiling the Energy Potential of Marshmallow Deposits.pdf
Unveiling the Energy Potential of Marshmallow Deposits.pdf
Erdal Coalmaker
 
Comparing Evolved Extractive Text Summary Scores of Bidirectional Encoder Rep...
Comparing Evolved Extractive Text Summary Scores of Bidirectional Encoder Rep...Comparing Evolved Extractive Text Summary Scores of Bidirectional Encoder Rep...
Comparing Evolved Extractive Text Summary Scores of Bidirectional Encoder Rep...
University of Maribor
 
BREEDING METHODS FOR DISEASE RESISTANCE.pptx
BREEDING METHODS FOR DISEASE RESISTANCE.pptxBREEDING METHODS FOR DISEASE RESISTANCE.pptx
BREEDING METHODS FOR DISEASE RESISTANCE.pptx
RASHMI M G
 
Toxic effects of heavy metals : Lead and Arsenic
Toxic effects of heavy metals : Lead and ArsenicToxic effects of heavy metals : Lead and Arsenic
Toxic effects of heavy metals : Lead and Arsenic
sanjana502982
 
Remote Sensing and Computational, Evolutionary, Supercomputing, and Intellige...
Remote Sensing and Computational, Evolutionary, Supercomputing, and Intellige...Remote Sensing and Computational, Evolutionary, Supercomputing, and Intellige...
Remote Sensing and Computational, Evolutionary, Supercomputing, and Intellige...
University of Maribor
 
20240520 Planning a Circuit Simulator in JavaScript.pptx
20240520 Planning a Circuit Simulator in JavaScript.pptx20240520 Planning a Circuit Simulator in JavaScript.pptx
20240520 Planning a Circuit Simulator in JavaScript.pptx
Sharon Liu
 
Orion Air Quality Monitoring Systems - CWS
Orion Air Quality Monitoring Systems - CWSOrion Air Quality Monitoring Systems - CWS
Orion Air Quality Monitoring Systems - CWS
Columbia Weather Systems
 
如何办理(uvic毕业证书)维多利亚大学毕业证本科学位证书原版一模一样
如何办理(uvic毕业证书)维多利亚大学毕业证本科学位证书原版一模一样如何办理(uvic毕业证书)维多利亚大学毕业证本科学位证书原版一模一样
如何办理(uvic毕业证书)维多利亚大学毕业证本科学位证书原版一模一样
yqqaatn0
 

Recently uploaded (20)

The use of Nauplii and metanauplii artemia in aquaculture (brine shrimp).pptx
The use of Nauplii and metanauplii artemia in aquaculture (brine shrimp).pptxThe use of Nauplii and metanauplii artemia in aquaculture (brine shrimp).pptx
The use of Nauplii and metanauplii artemia in aquaculture (brine shrimp).pptx
 
3D Hybrid PIC simulation of the plasma expansion (ISSS-14)
3D Hybrid PIC simulation of the plasma expansion (ISSS-14)3D Hybrid PIC simulation of the plasma expansion (ISSS-14)
3D Hybrid PIC simulation of the plasma expansion (ISSS-14)
 
DMARDs Pharmacolgy Pharm D 5th Semester.pdf
DMARDs Pharmacolgy Pharm D 5th Semester.pdfDMARDs Pharmacolgy Pharm D 5th Semester.pdf
DMARDs Pharmacolgy Pharm D 5th Semester.pdf
 
mô tả các thí nghiệm về đánh giá tác động dòng khí hóa sau đốt
mô tả các thí nghiệm về đánh giá tác động dòng khí hóa sau đốtmô tả các thí nghiệm về đánh giá tác động dòng khí hóa sau đốt
mô tả các thí nghiệm về đánh giá tác động dòng khí hóa sau đốt
 
Leaf Initiation, Growth and Differentiation.pdf
Leaf Initiation, Growth and Differentiation.pdfLeaf Initiation, Growth and Differentiation.pdf
Leaf Initiation, Growth and Differentiation.pdf
 
Observation of Io’s Resurfacing via Plume Deposition Using Ground-based Adapt...
Observation of Io’s Resurfacing via Plume Deposition Using Ground-based Adapt...Observation of Io’s Resurfacing via Plume Deposition Using Ground-based Adapt...
Observation of Io’s Resurfacing via Plume Deposition Using Ground-based Adapt...
 
Deep Software Variability and Frictionless Reproducibility
Deep Software Variability and Frictionless ReproducibilityDeep Software Variability and Frictionless Reproducibility
Deep Software Variability and Frictionless Reproducibility
 
Travis Hills' Endeavors in Minnesota: Fostering Environmental and Economic Pr...
Travis Hills' Endeavors in Minnesota: Fostering Environmental and Economic Pr...Travis Hills' Endeavors in Minnesota: Fostering Environmental and Economic Pr...
Travis Hills' Endeavors in Minnesota: Fostering Environmental and Economic Pr...
 
Phenomics assisted breeding in crop improvement
Phenomics assisted breeding in crop improvementPhenomics assisted breeding in crop improvement
Phenomics assisted breeding in crop improvement
 
Nucleic Acid-its structural and functional complexity.
Nucleic Acid-its structural and functional complexity.Nucleic Acid-its structural and functional complexity.
Nucleic Acid-its structural and functional complexity.
 
ANAMOLOUS SECONDARY GROWTH IN DICOT ROOTS.pptx
ANAMOLOUS SECONDARY GROWTH IN DICOT ROOTS.pptxANAMOLOUS SECONDARY GROWTH IN DICOT ROOTS.pptx
ANAMOLOUS SECONDARY GROWTH IN DICOT ROOTS.pptx
 
Eukaryotic Transcription Presentation.pptx
Eukaryotic Transcription Presentation.pptxEukaryotic Transcription Presentation.pptx
Eukaryotic Transcription Presentation.pptx
 
Unveiling the Energy Potential of Marshmallow Deposits.pdf
Unveiling the Energy Potential of Marshmallow Deposits.pdfUnveiling the Energy Potential of Marshmallow Deposits.pdf
Unveiling the Energy Potential of Marshmallow Deposits.pdf
 
Comparing Evolved Extractive Text Summary Scores of Bidirectional Encoder Rep...
Comparing Evolved Extractive Text Summary Scores of Bidirectional Encoder Rep...Comparing Evolved Extractive Text Summary Scores of Bidirectional Encoder Rep...
Comparing Evolved Extractive Text Summary Scores of Bidirectional Encoder Rep...
 
BREEDING METHODS FOR DISEASE RESISTANCE.pptx
BREEDING METHODS FOR DISEASE RESISTANCE.pptxBREEDING METHODS FOR DISEASE RESISTANCE.pptx
BREEDING METHODS FOR DISEASE RESISTANCE.pptx
 
Toxic effects of heavy metals : Lead and Arsenic
Toxic effects of heavy metals : Lead and ArsenicToxic effects of heavy metals : Lead and Arsenic
Toxic effects of heavy metals : Lead and Arsenic
 
Remote Sensing and Computational, Evolutionary, Supercomputing, and Intellige...
Remote Sensing and Computational, Evolutionary, Supercomputing, and Intellige...Remote Sensing and Computational, Evolutionary, Supercomputing, and Intellige...
Remote Sensing and Computational, Evolutionary, Supercomputing, and Intellige...
 
20240520 Planning a Circuit Simulator in JavaScript.pptx
20240520 Planning a Circuit Simulator in JavaScript.pptx20240520 Planning a Circuit Simulator in JavaScript.pptx
20240520 Planning a Circuit Simulator in JavaScript.pptx
 
Orion Air Quality Monitoring Systems - CWS
Orion Air Quality Monitoring Systems - CWSOrion Air Quality Monitoring Systems - CWS
Orion Air Quality Monitoring Systems - CWS
 
如何办理(uvic毕业证书)维多利亚大学毕业证本科学位证书原版一模一样
如何办理(uvic毕业证书)维多利亚大学毕业证本科学位证书原版一模一样如何办理(uvic毕业证书)维多利亚大学毕业证本科学位证书原版一模一样
如何办理(uvic毕业证书)维多利亚大学毕业证本科学位证书原版一模一样
 

Type-Safe Evolution of 
Web Services

  • 1. Type-Safe Evolution of 
 Web Services João Campinhos, João Costa Seco, Jácome Cunha
 NOVA LINCS, Universidade NOVA de Lisboa, Portugal j.campinhos@campus.fct.unl.pt, joao.seco@fct.unl.pt, jacome@fct.unl.pt Second International Workshop on Variability and Complexity in Software Design VACE @ ICSE 2017 27 May, 2017 - Buenos Aires, Argentina
  • 2. Problem • Mobile/Web apps based on micro or web services have had significant growth (smartphones explosion) • Client and server are loosely coupled • Using such kind of interfaces provides almost no guarantees to the (client) developer in terms of evolution • Changes to service interfaces can be introduced at any moment, causing the clients to fail • All of us now this evolution happens all the time 2
  • 3. An Example of a Web Service for Users - v1.0 server implementation – version 1.0 user() => { name: “John Doe” } client implementation – version 1.0 user().name.trim() 3
  • 4. Server Evolution server implementation – version 2.0 user() => { name:{ first: “John”, last: “Doe” }} client implementation – version 1.0 user().name.trim() 4
  • 5. Clients Need to Go Along… server implementation – version 2.0 user() => { name:{ first: “John”, last: "Doe" }} client implementation – version 2.0 user().name.first + “ “ + user().name.last 5
  • 6. Several Issues • It is probably not feasible to update all clients to the latest version at the same time • It is probably not possible to keep all service interfaces and maintain them all • If the client moves from version A to version B, then all the code needs to move (not incremental) 6
  • 7. How can we help server and client developers cope with evolution? ? 7
  • 8. Towards a Solution •Coexistence Principle •Compatibility Principle •Safety Principle •Modularity Principle 8
  • 9. Coexistence Principle • Coexistence Principle: to make all the existing versions available as a complete application, as a unique code base • Making use of annotations in the client requests and in the server code to identify which version(s) to use to attend a request • Both versions 1.0 and 2.0 of the server should coexist at the same time and should be usable by a client, both at the same time 9
  • 10. Coexistence Principle { (version = ’1.0’) => { var currentuser = {name: “John Doe”}; function user() : {name: string} { return currentuser; } } (version = ’2.0’) => { var currentuser = {name: {first:”John”, last: ”Doe”}}; function user() : {name: {first: string, last: string}} {
 return currentuser; } } } 10
  • 11. Reuse •The coexistence of versions only makes sense if it is possible to reuse code across versions •We introduce a language construct that allows the annotation of an expression e with a version v where it should be evaluated
 
 (version = ‘v’) => e 11
  • 12. 12 (version = ’1.0’) => { var currentuser = {name: “John Doe”}; function user() : {name: string} { return (version ‘2.0’) => { name: user().first + “ “ + user().last }; } } (version = ’2.0’) => { var currentuser = {name: {first:”John”, last: ”Doe”}}; function user() : {name: {first: string, last: string}} {
 return currentuser; } }
  • 13. Small Change to v2.0 … (version = ’2.0’) => { var currentuser = {name: {first:”John”, last: ”Doe”}}; function user() : {name: {first: string, last: string}} {
 return currentuser; } } (version = ’2.1’) => { function user(): {name:{first: string, last: string}, age:int} { return (version = ’2.0’) => {user(), age: 42}; } } 13
  • 14. 14 • In this case, the type of the response in version 2.1 is a subtype of the response in version 2.0 • In many cases, it is still possible for clients to interact with the new version • This makes it possible for version 2.1 to be used whenever version 2.0 is requested
  • 15. Compatibility Principle • Compatibility Principle: a system should serve its clients with (type) compatible versions at all times • Our solution is to use a relation on versions that embeds the notion of compatibility between versions • We introduce version patterns which define the base version for searching the correct implementation 15
  • 16. 16 … (version = ’2.0’) => { var currentuser = {name: {first:”John”, last: ”Doe”}}; function user() : {name: {first: string, last: string}} {
 return currentuser; } } (version = ’2.1’) => { function user(): {name:{first: string, last: string}, age:int} { return (version = ’2.0’) => {user(), age: 42}; return (version = ’2.*’) => {user(), age: 42}; } }
  • 17. An Example of a Relation 17 1.0 2.0 2.1 1.0-A user():{name:string} user():{name:{first: string, last: string}} user():{name:{first: string, last: string}, age:int} strictfree subtyping
  • 18. Compatibility Modes •Strict: all the changes from one version to another preserve the types of all declared identifiers (functions and variables) •Subtyping: all changes from one version to another follow the subtype relation •Free: does not constraint the changes on the type signatures, as to allow the developer to arbitrarily change the source code 18
  • 19. An Example of a Relation 19 1.0 2.0 2.1 1.0-A user():{name:string} user():{name:{first: string, last: string}} user():{name:{first: string, last: string}, age:int} strictfree subtyping
  • 20. Back to the Client Code - Subtyping Mode second client implementation – version 2.0 (version = ’2.*’) => { user().name.first } • Client code maybe still be in version 2.0, but if it requests the most updated version of the service, version 2.1 will be served 20
  • 21. Type Checker and Dispatching System • The static type checker considers all versions and the compatibility modes between them to typecheck the code base • The runtime dispatching system also takes into consideration the relation between the different version to serve the appropriate one 21
  • 22. Safety Principle •A third (and more general) principle becomes essential to reach a sound solution •Safety Principle: all possible entry points of the system should be type safe, in all versions, and considering all possible version redirections given by the version compatibility relation 22
  • 23. Modularity Principle •Modularity Principle: the static verification of code and the dynamic dispatching of requests and execution should be decoupled from the actual definition of what a version is and how versions relate •This implies the relation is defined by the server developer to relate any versions using any compatibility mode 23
  • 24. Open-Source Prototype Implementation 24 Annotated JavaScript Code Syntactic Analysis Version Type Checker Flow Transpiler JavaScript Code Router Request (version, mode) Function Relation AST http://github.com/niverso Babel Ours Flow Syntax Type Checker
  • 25. Conclusions & Future Work •We introduced a new programming model to develop and evolve software with multiple versions at the same time •It copes with evolution using version compatibility modes •Our approach is flexible as it is parametric on any version control system developers may use •The type system we developed can typecheck programs with several versions at the same time •The dispatching function dynamically decides what is the best version of a particular component for each request 25
  • 26. Conclusions & Future Work •As a proof of concept we have implemented our programming model as a prototype using the Flow typechecker and JavaScript •As future work, we want to formally certify the soundness of the approach •Also, experimental work must be performed with larger case-studies •We would also like to develop an IDE with this programming model built-in 26