SlideShare a Scribd company logo
1 of 62
Download to read offline
Formalising Solutions to REST API Practices
as Design (Anti)patterns
Van Tuan Tran, Manel Abdellatif and Yann-Gaël Guéhéneuc
Presenting at The 19th International Conference on Service-Oriented Computing
Table of Contents
1. Introduction
2. Related Work
3. Approach
4. (Anti)patterns
5. Evaluations
6. Discussion
7. Conclusion
2
1 - Introduction
3
1 - Introduction - Context
4
https://github.com/features/codespaces - https://www.windy.com/
1 - Introduction - Context
5
1 - Introduction - Context
6
REpresentational State Transfer
Application Programming Interface
1 - Introduction - Context
7
REpresentational State Transfer
Application Programming Interface
1 - Introduction - Terms
8
Practice noun
/ˈpræktɪs/
way of doing something
Good practice
good way to implement the REST API
Bad practice
Bad way to implement the REST API
https://www.oxfordlearnersdictionaries.com/us/definition/english/practice_1
1 - Introduction - Terms
9
Anti-pattern
“A commonly occurring solution to a problem that generates
negative consequences”
Problem Bad solution(s) Alternative good solution(s)
1 - Introduction
10
We propose 3 contributions
● Review academic and gray literature to identify REST API practices
● Propose practical solutions to these practices
● Validate our solutions with surveys and interviews
2 - Related Work
11
2 - Related Work - Practices
12
2010 - Content Negotiations
2011 - CRUDYs URIs
Use the wrong HTTP Verbs
Ignoring MIME Type
Context-less resource name
Non-hierarchical nodes
Singularized/Pluralized Nodes
List Pagination
2012 - API Versioning
Masse
2008 - Breaking Self-descriptiveness
Forgetting Hypermedia
Ignoring MIME type
Ignoring status code
Misusing cookies
Use the wrong HTTP Verbs
Stefan Tilkov
Rodriguez,
Crasso,
Zunino, and
Campo
Fredrich
2 - Related Work - Practices
13
2010 - Content Negotiations
2011 - CRUDYs URIs
Use the wrong HTTP Verbs
Ignoring MIME Type
Context-less resource name
Non-hierarchical nodes
Singularized/Pluralized Nodes
List Pagination
2012 - API Versioning
2008 - Breaking Self-descriptiveness
Forgetting Hypermedia
Ignoring MIME type
Ignoring status code
Misusing cookies
Use the wrong HTTP Verbs
Non-pertinent documentation - 2017
Palma et al.
2 - Related Work - Practices
14
2010 - Content Negotiations
2011 - CRUDYs URIs
Use the wrong HTTP Verbs
Ignoring MIME Type
Context-less resource name
Non-hierarchical nodes
Singularized/Pluralized Nodes
List Pagination
2012 - API Versioning
2008 - Breaking Self-descriptiveness
Forgetting Hypermedia
Ignoring MIME type
Ignoring status code
Misusing cookies
Use the wrong HTTP Verbs
Non-pertinent documentation - 2017
Server Timeout - 2021
Post-Put-Patch return - 2021
2 - Related Work - Existing Solutions
15
● Content Negotiation
● Forgetting Hypermedia
● API Versioning
● Server Timeout
● Response Caching
● List Pagination
2 - Related Work - Existing Solutions
16
● Content Negotiation
● Forgetting Hypermedia
● API Versioning
● Server Timeout
● Response Caching
● List Pagination
XML
JSON
Lemlouma
and Layaïda
2 - Related Work - Existing Solutions
17
● Content Negotiation
● Forgetting Hypermedia
● API Versioning
● Server Timeout
● Response Caching
● List Pagination
XML
JSON
Butler
2 - Related Work - Existing Solutions
18
● Content Negotiation
● Forgetting Hypermedia
● API Versioning
● Server Timeout
● Response Caching
● List Pagination
wrapper
Liskin, Singer,
and Schneider
2 - Related Work - Existing Solutions
19
● Content Negotiation
● Forgetting Hypermedia
● API Versioning
● Server Timeout
● Response Caching
● List Pagination
Chain of Adapter
Kaminski, Litoiu,
and Muller
2 - Related Work - Existing Solutions
20
● Content Negotiation
● Forgetting Hypermedia
● API Versioning
● Server Timeout
● Response Caching
● List Pagination
Version 1
Version 2
Version 1
Version 2
Leitner, Michlmayr,
Rosenberg, and
Dustdar
2 - Related Work - Existing Solutions
21
● Content Negotiation
● Forgetting Hypermedia
● API Versioning
● Server Timeout
● Response Caching
● List Pagination
Eastbury et al.
2 - Related Work - Existing Solutions
22
● Content Negotiation
● Forgetting Hypermedia
● API Versioning
● Server Timeout
● Response Caching
● List Pagination
https://github.com/campusMVP/dotnetCoreLogoPack - https://spring.io/trademarks
3 - Approach
23
24
2 - Approach - Literature Review
25
2 - Approach - Categorization
Technical Non-technical
Content negotiation Entity Endpoint
Endpoint redirection Contextless Resource name
Entity Linking Non-hierarchical Nodes
Response caching Amorphous URIs
API Versioning CRUDy URIs
Server Timeout Singularized & Pluralized Nodes
POST-PUT-PATCH Return Non-pertinent Documentation
List Pagination Breaking Self-descriptiveness
Ignoring status code
Using the wrong HTTP Verbs
Misusing Cookies
Architectural
Devs pay attention
26
2 - Approach - Looking for Solutions
4 - REST API Anti-patterns
27
4 - REST API Anti-patterns - Overview
28
● Practice name
● Problem
● Expected result
● Solution
4 - REST API Anti-patterns - Sample Implementation
29
https://github.com/huntertran/restapi-practices-impl
4 - REST API Anti-patterns - Content Negotiation
30
● Problem
XML
JSON
2 3
1
4 - REST API Anti-patterns - Content Negotiation
31
● Expected result
XML
JSON
default
● JSON-XML
● JPG, PNG, Base64
● CSV, XLSX, ODS
● JSON-XML
● JPG, PNG, Base64
● CSV, XLSX, ODS
Easily modifiable
● GSON/Jackson/Javax.Json
● Javax.ImageIO/ImageJ/imgscalr
● FileReader/XStream/JacksonXML
4 - REST API Anti-patterns - Content Negotiation
32
● Solution
4 - REST API Anti-patterns - Content Negotiation
33
● Comparison
Java Spring ASP.NET Core Our solution
Common media types Yes Yes Yes
Customizable serializer No Yes Yes
No data annotation on model No Yes Yes
Built-in support ignorable Yes Yes N/A
4 - REST API Anti-patterns - Endpoint Redirection
34
● Problem
New location of
moved resources
O
l
d
U
R
I
H
T
T
P
3
0
2
M
o
v
e
d
4 - REST API Anti-patterns - Endpoint Redirection
35
● Solution
4 - REST API Anti-patterns - Entity Linking
36
● Problem
{
"post": {
"title": "Lorem ipsum",
"content": "Lorem ipsum",
"links": [
{
"rel": "comment",
"method": "post",
"uri": "/post/123/comment"
},
{
"rel": "like",
"method": "get",
"uri": "/post/123/like"
}
]
}
}
4 - REST API Anti-patterns - Entity Linking
37
● Solution
4 - REST API Anti-patterns - API Versioning
38
● Problem
Version 1
Version 2
Version 1
Version 2
4 - REST API Anti-patterns - API Versioning
39
● Solution
4 - REST API Anti-patterns - Server Timeout
40
● Problem
4 - REST API Anti-patterns - Server Timeout
41
● Solution
4 - REST API Anti-patterns - POST-PUT-PATCH return
42
● Problem
CREATE - UPDATE
HTTP 200 OK
Is object created correctly?
4 - REST API Anti-patterns - POST-PUT-PATCH return
43
● Solution
5 - Evaluations
44
5 - Evaluations - Survey Design
45
● Have you faced this problem(s)
in some of your project
● Is the proposed solution a good
solution?
https://acmsigsoft.github.io/EmpiricalStandards/docs/
55 participants 5 participants
5 - Evaluations - Survey Result - Age Groups & Education
46
Age Groups Education Levels
5 - Evaluations - Survey Result - Profession
47
5 - Evaluations - Survey Result - Experience
48
5 - Evaluations - Survey Result - Countries
49
5 - Evaluations - Survey Result - Positive on Solutions
50
Face this problem Std. dev. Good solution Std. dev.
Content Negotiation 52.40% 2.289 76.20% 1.952
Endpoint Redirection 45% 2.225 75% 1.936
Entity Linking 47.40% 2.177 57.90% 2.152
API Versioning 72.20% 1.901 72.20% 1.901
Server Timeout 77.80% 1.763 66.70% 1.999
POST-PUT-PATCH return 58.80% 2.029 82.40% 1.57
70%
5 - Evaluations - Survey Result - Explained
51
Entity Linking - 57.9% agreed good solution
Visitor Pattern
Visitor Pattern
5 - Evaluations - Survey Result - Explained
52
Entity Linking - 57.9% agreed good solution
List of permissions
5 - Evaluations - Survey Result - Explained
53
Server Timeout - 66.7% agreed good solution
HTTP Polling
Publisher
HTTP/2 gRPC
5 - Evaluations - Survey Result - Explained
54
Server Timeout - 66.7% agreed good solution
WebSocket Tunnel
HTTP Polling
5 - Evaluations - Survey Result - Explained
55
Server Timeout - 66.7% agreed good solution
Publisher
5 - Evaluations - Survey Result - Explained
https://engineering.salesforce.com/the-full-picture-on-http-2-and-hol-blocking-7f964b34d205 56
Server Timeout - 66.7% agreed good solution
HTTP/2 gRPC
Forced Encryption TPC Head-of-line Blocking
6 - Discussion
57
6 - Discussion - Internal Threats
58
JavaScript Go Groovy Java
Gin
Grails Apache Struts
6 - Discussion - External Threats
59
Year of experiences
Domain Knowledge
Favor new technologies
Easier to spot potential
problems of the practices
7 - Conclusion
60
7 - Conclusion
61
Our contributions:
1. Review REST API practices in both academic and gray literature.
2. Provide concrete solutions to 6 technical practices.
3. Validate the solutions with professional developers.
Thank you
Q & A
62

More Related Content

Similar to ICSOC'21

Creating Interactive Olap Applications With My Sql Enterprise And Mondrian Pr...
Creating Interactive Olap Applications With My Sql Enterprise And Mondrian Pr...Creating Interactive Olap Applications With My Sql Enterprise And Mondrian Pr...
Creating Interactive Olap Applications With My Sql Enterprise And Mondrian Pr...
Indus Khaitan
 

Similar to ICSOC'21 (20)

Experimentation Platform on Hadoop
Experimentation Platform on HadoopExperimentation Platform on Hadoop
Experimentation Platform on Hadoop
 
eBay Experimentation Platform on Hadoop
eBay Experimentation Platform on HadoopeBay Experimentation Platform on Hadoop
eBay Experimentation Platform on Hadoop
 
sem5.pdf
sem5.pdfsem5.pdf
sem5.pdf
 
The Effect of Third Party Implementations on Reproducibility
The Effect of Third Party Implementations on ReproducibilityThe Effect of Third Party Implementations on Reproducibility
The Effect of Third Party Implementations on Reproducibility
 
Vue.js Use Cases
Vue.js Use CasesVue.js Use Cases
Vue.js Use Cases
 
Using REST and UI Testing to Test Ajax Web Applications
Using REST and UI Testing to Test Ajax Web ApplicationsUsing REST and UI Testing to Test Ajax Web Applications
Using REST and UI Testing to Test Ajax Web Applications
 
SERENE 2014 Workshop: Paper "Combined Error Propagation Analysis and Runtime ...
SERENE 2014 Workshop: Paper "Combined Error Propagation Analysis and Runtime ...SERENE 2014 Workshop: Paper "Combined Error Propagation Analysis and Runtime ...
SERENE 2014 Workshop: Paper "Combined Error Propagation Analysis and Runtime ...
 
Pentaho PDI and the Jare Ruleengine
Pentaho PDI and the Jare RuleenginePentaho PDI and the Jare Ruleengine
Pentaho PDI and the Jare Ruleengine
 
Creating Interactive Olap Applications With My Sql Enterprise And Mondrian Pr...
Creating Interactive Olap Applications With My Sql Enterprise And Mondrian Pr...Creating Interactive Olap Applications With My Sql Enterprise And Mondrian Pr...
Creating Interactive Olap Applications With My Sql Enterprise And Mondrian Pr...
 
Resource Discovery Landscape
Resource Discovery LandscapeResource Discovery Landscape
Resource Discovery Landscape
 
Introduction to SoapUI day 1
Introduction to SoapUI day 1Introduction to SoapUI day 1
Introduction to SoapUI day 1
 
Soap UI - Getting started
Soap UI - Getting startedSoap UI - Getting started
Soap UI - Getting started
 
Legacy Renewal of Central Framework in the Enterprise
Legacy Renewal of Central Framework in the EnterpriseLegacy Renewal of Central Framework in the Enterprise
Legacy Renewal of Central Framework in the Enterprise
 
It's all about feedback - code review as a great tool in the agile toolbox
It's all about feedback - code review as a great tool in the agile toolboxIt's all about feedback - code review as a great tool in the agile toolbox
It's all about feedback - code review as a great tool in the agile toolbox
 
SFScon18 - Kurt Ranalter - Leonhard Holzer - API level regression testing: a ...
SFScon18 - Kurt Ranalter - Leonhard Holzer - API level regression testing: a ...SFScon18 - Kurt Ranalter - Leonhard Holzer - API level regression testing: a ...
SFScon18 - Kurt Ranalter - Leonhard Holzer - API level regression testing: a ...
 
GraphQL Advanced
GraphQL AdvancedGraphQL Advanced
GraphQL Advanced
 
Agile Engineering Environment – 2017
Agile Engineering Environment – 2017Agile Engineering Environment – 2017
Agile Engineering Environment – 2017
 
Agile Engineering Environment – 2017
Agile Engineering Environment – 2017Agile Engineering Environment – 2017
Agile Engineering Environment – 2017
 
Agile engineering environment 50 minutes or less
Agile engineering environment   50 minutes or lessAgile engineering environment   50 minutes or less
Agile engineering environment 50 minutes or less
 
Dust.js
Dust.jsDust.js
Dust.js
 

More from Yann-Gaël Guéhéneuc

Evolution and Examples of Java Features, from Java 1.7 to Java 22
Evolution and Examples of Java Features, from Java 1.7 to Java 22Evolution and Examples of Java Features, from Java 1.7 to Java 22
Evolution and Examples of Java Features, from Java 1.7 to Java 22
Yann-Gaël Guéhéneuc
 
Consequences and Principles of Software Quality v0.3
Consequences and Principles of Software Quality v0.3Consequences and Principles of Software Quality v0.3
Consequences and Principles of Software Quality v0.3
Yann-Gaël Guéhéneuc
 
On Reflection in OO Programming Languages v1.6
On Reflection in OO Programming Languages v1.6On Reflection in OO Programming Languages v1.6
On Reflection in OO Programming Languages v1.6
Yann-Gaël Guéhéneuc
 

More from Yann-Gaël Guéhéneuc (20)

Advice for writing a NSERC Discovery grant application v0.5
Advice for writing a NSERC Discovery grant application v0.5Advice for writing a NSERC Discovery grant application v0.5
Advice for writing a NSERC Discovery grant application v0.5
 
Ptidej Architecture, Design, and Implementation in Action v2.1
Ptidej Architecture, Design, and Implementation in Action v2.1Ptidej Architecture, Design, and Implementation in Action v2.1
Ptidej Architecture, Design, and Implementation in Action v2.1
 
Evolution and Examples of Java Features, from Java 1.7 to Java 22
Evolution and Examples of Java Features, from Java 1.7 to Java 22Evolution and Examples of Java Features, from Java 1.7 to Java 22
Evolution and Examples of Java Features, from Java 1.7 to Java 22
 
Consequences and Principles of Software Quality v0.3
Consequences and Principles of Software Quality v0.3Consequences and Principles of Software Quality v0.3
Consequences and Principles of Software Quality v0.3
 
Some Pitfalls with Python and Their Possible Solutions v0.9
Some Pitfalls with Python and Their Possible Solutions v0.9Some Pitfalls with Python and Their Possible Solutions v0.9
Some Pitfalls with Python and Their Possible Solutions v0.9
 
An Explanation of the Unicode, the Text Encoding Standard, Its Usages and Imp...
An Explanation of the Unicode, the Text Encoding Standard, Its Usages and Imp...An Explanation of the Unicode, the Text Encoding Standard, Its Usages and Imp...
An Explanation of the Unicode, the Text Encoding Standard, Its Usages and Imp...
 
An Explanation of the Halting Problem and Its Consequences
An Explanation of the Halting Problem and Its ConsequencesAn Explanation of the Halting Problem and Its Consequences
An Explanation of the Halting Problem and Its Consequences
 
Are CPUs VMs Like Any Others? v1.0
Are CPUs VMs Like Any Others? v1.0Are CPUs VMs Like Any Others? v1.0
Are CPUs VMs Like Any Others? v1.0
 
Informaticien(ne)s célèbres (v1.0.2, 19/02/20)
Informaticien(ne)s célèbres (v1.0.2, 19/02/20)Informaticien(ne)s célèbres (v1.0.2, 19/02/20)
Informaticien(ne)s célèbres (v1.0.2, 19/02/20)
 
Well-known Computer Scientists v1.0.2
Well-known Computer Scientists v1.0.2Well-known Computer Scientists v1.0.2
Well-known Computer Scientists v1.0.2
 
On Java Generics, History, Use, Caveats v1.1
On Java Generics, History, Use, Caveats v1.1On Java Generics, History, Use, Caveats v1.1
On Java Generics, History, Use, Caveats v1.1
 
On Reflection in OO Programming Languages v1.6
On Reflection in OO Programming Languages v1.6On Reflection in OO Programming Languages v1.6
On Reflection in OO Programming Languages v1.6
 
Vissoft21.ppt
Vissoft21.pptVissoft21.ppt
Vissoft21.ppt
 
Service computation20.ppt
Service computation20.pptService computation20.ppt
Service computation20.ppt
 
Serp4 iot20.ppt
Serp4 iot20.pptSerp4 iot20.ppt
Serp4 iot20.ppt
 
Msr20.ppt
Msr20.pptMsr20.ppt
Msr20.ppt
 
Iwesep19.ppt
Iwesep19.pptIwesep19.ppt
Iwesep19.ppt
 
Icsoc20.ppt
Icsoc20.pptIcsoc20.ppt
Icsoc20.ppt
 
Icsoc18.ppt
Icsoc18.pptIcsoc18.ppt
Icsoc18.ppt
 
Icsm20.ppt
Icsm20.pptIcsm20.ppt
Icsm20.ppt
 

Recently uploaded

AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
VictorSzoltysek
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
mohitmore19
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
masabamasaba
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
masabamasaba
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
masabamasaba
 

Recently uploaded (20)

Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
 
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
SHRMPro HRMS Software Solutions Presentation
SHRMPro HRMS Software Solutions PresentationSHRMPro HRMS Software Solutions Presentation
SHRMPro HRMS Software Solutions Presentation
 

ICSOC'21

  • 1. Formalising Solutions to REST API Practices as Design (Anti)patterns Van Tuan Tran, Manel Abdellatif and Yann-Gaël Guéhéneuc Presenting at The 19th International Conference on Service-Oriented Computing
  • 2. Table of Contents 1. Introduction 2. Related Work 3. Approach 4. (Anti)patterns 5. Evaluations 6. Discussion 7. Conclusion 2
  • 4. 1 - Introduction - Context 4 https://github.com/features/codespaces - https://www.windy.com/
  • 5. 1 - Introduction - Context 5
  • 6. 1 - Introduction - Context 6 REpresentational State Transfer Application Programming Interface
  • 7. 1 - Introduction - Context 7 REpresentational State Transfer Application Programming Interface
  • 8. 1 - Introduction - Terms 8 Practice noun /ˈpræktɪs/ way of doing something Good practice good way to implement the REST API Bad practice Bad way to implement the REST API https://www.oxfordlearnersdictionaries.com/us/definition/english/practice_1
  • 9. 1 - Introduction - Terms 9 Anti-pattern “A commonly occurring solution to a problem that generates negative consequences” Problem Bad solution(s) Alternative good solution(s)
  • 10. 1 - Introduction 10 We propose 3 contributions ● Review academic and gray literature to identify REST API practices ● Propose practical solutions to these practices ● Validate our solutions with surveys and interviews
  • 11. 2 - Related Work 11
  • 12. 2 - Related Work - Practices 12 2010 - Content Negotiations 2011 - CRUDYs URIs Use the wrong HTTP Verbs Ignoring MIME Type Context-less resource name Non-hierarchical nodes Singularized/Pluralized Nodes List Pagination 2012 - API Versioning Masse 2008 - Breaking Self-descriptiveness Forgetting Hypermedia Ignoring MIME type Ignoring status code Misusing cookies Use the wrong HTTP Verbs Stefan Tilkov Rodriguez, Crasso, Zunino, and Campo Fredrich
  • 13. 2 - Related Work - Practices 13 2010 - Content Negotiations 2011 - CRUDYs URIs Use the wrong HTTP Verbs Ignoring MIME Type Context-less resource name Non-hierarchical nodes Singularized/Pluralized Nodes List Pagination 2012 - API Versioning 2008 - Breaking Self-descriptiveness Forgetting Hypermedia Ignoring MIME type Ignoring status code Misusing cookies Use the wrong HTTP Verbs Non-pertinent documentation - 2017 Palma et al.
  • 14. 2 - Related Work - Practices 14 2010 - Content Negotiations 2011 - CRUDYs URIs Use the wrong HTTP Verbs Ignoring MIME Type Context-less resource name Non-hierarchical nodes Singularized/Pluralized Nodes List Pagination 2012 - API Versioning 2008 - Breaking Self-descriptiveness Forgetting Hypermedia Ignoring MIME type Ignoring status code Misusing cookies Use the wrong HTTP Verbs Non-pertinent documentation - 2017 Server Timeout - 2021 Post-Put-Patch return - 2021
  • 15. 2 - Related Work - Existing Solutions 15 ● Content Negotiation ● Forgetting Hypermedia ● API Versioning ● Server Timeout ● Response Caching ● List Pagination
  • 16. 2 - Related Work - Existing Solutions 16 ● Content Negotiation ● Forgetting Hypermedia ● API Versioning ● Server Timeout ● Response Caching ● List Pagination XML JSON Lemlouma and Layaïda
  • 17. 2 - Related Work - Existing Solutions 17 ● Content Negotiation ● Forgetting Hypermedia ● API Versioning ● Server Timeout ● Response Caching ● List Pagination XML JSON Butler
  • 18. 2 - Related Work - Existing Solutions 18 ● Content Negotiation ● Forgetting Hypermedia ● API Versioning ● Server Timeout ● Response Caching ● List Pagination wrapper Liskin, Singer, and Schneider
  • 19. 2 - Related Work - Existing Solutions 19 ● Content Negotiation ● Forgetting Hypermedia ● API Versioning ● Server Timeout ● Response Caching ● List Pagination Chain of Adapter Kaminski, Litoiu, and Muller
  • 20. 2 - Related Work - Existing Solutions 20 ● Content Negotiation ● Forgetting Hypermedia ● API Versioning ● Server Timeout ● Response Caching ● List Pagination Version 1 Version 2 Version 1 Version 2 Leitner, Michlmayr, Rosenberg, and Dustdar
  • 21. 2 - Related Work - Existing Solutions 21 ● Content Negotiation ● Forgetting Hypermedia ● API Versioning ● Server Timeout ● Response Caching ● List Pagination Eastbury et al.
  • 22. 2 - Related Work - Existing Solutions 22 ● Content Negotiation ● Forgetting Hypermedia ● API Versioning ● Server Timeout ● Response Caching ● List Pagination https://github.com/campusMVP/dotnetCoreLogoPack - https://spring.io/trademarks
  • 24. 24 2 - Approach - Literature Review
  • 25. 25 2 - Approach - Categorization Technical Non-technical Content negotiation Entity Endpoint Endpoint redirection Contextless Resource name Entity Linking Non-hierarchical Nodes Response caching Amorphous URIs API Versioning CRUDy URIs Server Timeout Singularized & Pluralized Nodes POST-PUT-PATCH Return Non-pertinent Documentation List Pagination Breaking Self-descriptiveness Ignoring status code Using the wrong HTTP Verbs Misusing Cookies Architectural Devs pay attention
  • 26. 26 2 - Approach - Looking for Solutions
  • 27. 4 - REST API Anti-patterns 27
  • 28. 4 - REST API Anti-patterns - Overview 28 ● Practice name ● Problem ● Expected result ● Solution
  • 29. 4 - REST API Anti-patterns - Sample Implementation 29 https://github.com/huntertran/restapi-practices-impl
  • 30. 4 - REST API Anti-patterns - Content Negotiation 30 ● Problem XML JSON
  • 31. 2 3 1 4 - REST API Anti-patterns - Content Negotiation 31 ● Expected result XML JSON default ● JSON-XML ● JPG, PNG, Base64 ● CSV, XLSX, ODS ● JSON-XML ● JPG, PNG, Base64 ● CSV, XLSX, ODS Easily modifiable ● GSON/Jackson/Javax.Json ● Javax.ImageIO/ImageJ/imgscalr ● FileReader/XStream/JacksonXML
  • 32. 4 - REST API Anti-patterns - Content Negotiation 32 ● Solution
  • 33. 4 - REST API Anti-patterns - Content Negotiation 33 ● Comparison Java Spring ASP.NET Core Our solution Common media types Yes Yes Yes Customizable serializer No Yes Yes No data annotation on model No Yes Yes Built-in support ignorable Yes Yes N/A
  • 34. 4 - REST API Anti-patterns - Endpoint Redirection 34 ● Problem New location of moved resources O l d U R I H T T P 3 0 2 M o v e d
  • 35. 4 - REST API Anti-patterns - Endpoint Redirection 35 ● Solution
  • 36. 4 - REST API Anti-patterns - Entity Linking 36 ● Problem { "post": { "title": "Lorem ipsum", "content": "Lorem ipsum", "links": [ { "rel": "comment", "method": "post", "uri": "/post/123/comment" }, { "rel": "like", "method": "get", "uri": "/post/123/like" } ] } }
  • 37. 4 - REST API Anti-patterns - Entity Linking 37 ● Solution
  • 38. 4 - REST API Anti-patterns - API Versioning 38 ● Problem Version 1 Version 2 Version 1 Version 2
  • 39. 4 - REST API Anti-patterns - API Versioning 39 ● Solution
  • 40. 4 - REST API Anti-patterns - Server Timeout 40 ● Problem
  • 41. 4 - REST API Anti-patterns - Server Timeout 41 ● Solution
  • 42. 4 - REST API Anti-patterns - POST-PUT-PATCH return 42 ● Problem CREATE - UPDATE HTTP 200 OK Is object created correctly?
  • 43. 4 - REST API Anti-patterns - POST-PUT-PATCH return 43 ● Solution
  • 45. 5 - Evaluations - Survey Design 45 ● Have you faced this problem(s) in some of your project ● Is the proposed solution a good solution? https://acmsigsoft.github.io/EmpiricalStandards/docs/ 55 participants 5 participants
  • 46. 5 - Evaluations - Survey Result - Age Groups & Education 46 Age Groups Education Levels
  • 47. 5 - Evaluations - Survey Result - Profession 47
  • 48. 5 - Evaluations - Survey Result - Experience 48
  • 49. 5 - Evaluations - Survey Result - Countries 49
  • 50. 5 - Evaluations - Survey Result - Positive on Solutions 50 Face this problem Std. dev. Good solution Std. dev. Content Negotiation 52.40% 2.289 76.20% 1.952 Endpoint Redirection 45% 2.225 75% 1.936 Entity Linking 47.40% 2.177 57.90% 2.152 API Versioning 72.20% 1.901 72.20% 1.901 Server Timeout 77.80% 1.763 66.70% 1.999 POST-PUT-PATCH return 58.80% 2.029 82.40% 1.57 70%
  • 51. 5 - Evaluations - Survey Result - Explained 51 Entity Linking - 57.9% agreed good solution Visitor Pattern
  • 52. Visitor Pattern 5 - Evaluations - Survey Result - Explained 52 Entity Linking - 57.9% agreed good solution List of permissions
  • 53. 5 - Evaluations - Survey Result - Explained 53 Server Timeout - 66.7% agreed good solution HTTP Polling Publisher HTTP/2 gRPC
  • 54. 5 - Evaluations - Survey Result - Explained 54 Server Timeout - 66.7% agreed good solution WebSocket Tunnel HTTP Polling
  • 55. 5 - Evaluations - Survey Result - Explained 55 Server Timeout - 66.7% agreed good solution Publisher
  • 56. 5 - Evaluations - Survey Result - Explained https://engineering.salesforce.com/the-full-picture-on-http-2-and-hol-blocking-7f964b34d205 56 Server Timeout - 66.7% agreed good solution HTTP/2 gRPC Forced Encryption TPC Head-of-line Blocking
  • 58. 6 - Discussion - Internal Threats 58 JavaScript Go Groovy Java Gin Grails Apache Struts
  • 59. 6 - Discussion - External Threats 59 Year of experiences Domain Knowledge Favor new technologies Easier to spot potential problems of the practices
  • 61. 7 - Conclusion 61 Our contributions: 1. Review REST API practices in both academic and gray literature. 2. Provide concrete solutions to 6 technical practices. 3. Validate the solutions with professional developers.