SlideShare a Scribd company logo
1 of 29
Download to read offline
Reviewing
RESTful Web Apps
Takuto Wada (a.k.a id:t-wada or @t_wada)
Apr 12, 2014 @ RESTful Meetup
Takuto Wada
id: t-wada
@t_wada
github: twada
tl;dr:
REST is
infection
(Use it, love it, but think carefully.)
•WEB+DB PRESS vol.32
•Discussion around Hatena-Bookmark
•RubyKaigi 2006 Keynote by DHH
•WEB+DB PRESS vol.38
•RESTful Web Service
•RESTful Web APIs
REST and me (input)
•Java implementations (S2REST)
•WEB+DB PRESS vol.42 Experiencing
REST world with Restlet
• Practical REST talk series by gihyo
• #restwebtech book talk session
REST and me (output)
•Large Rails Project
•+1000 routes
•Tools for reviewing
•White board
•Chat (IRC, Skype, ...)
•Wiki
•diff
Target Project
1. Figure out the data set
2. Split the data set into resources
For each kind of resource:
3. Name the resources with URIs
4. Expose a subset of the uniform interface (GET/POST/PUT/DELETE)
5. Design the representation(s) accepted from the client
6. Design the representation(s) served to the client
7. Integrate this resource into existing resources, using hypermedia
links and forms (Connectedness matters)
8. Consider the typical course of events: what s supposed to happen?
9. Consider error conditions: what might go wrong?
Turning Requirements into Resources
•URL Design (verb, structure, query
params)
•fighting with the gravity of CRUD
•HTTP method
•HTTP status code
•Representation
•MECE of information
•Connectedness
Review point
Bad GET http://example.com/blog/getEntries
Good GET http://example.com/blog/entries
Bad POST http://example.com/blog/entries/add
Good POST http://example.com/blog/entries
Bad POST http://example.com/blog/entries/30/delete
Good DELETE http://example.com/blog/entries/30
Do not include verbs in URL
•/add, /delete, /update => Bad
•/edit => it depends (convention matters)
•Trying to use nouns
•/confirm -> /confirmation
•When the form of noun and verb are the
same => it depends
Do not include verbs in URL
• Tumblr s Bizarre URL => Too Bad
• http://www.tumblr.com/show/everything/by/me
• Reads like spoken language doesn t matter
• example.com/files/copy/:src/:dest => Bad
• destination is not subordinated to source
• Are they natural subordinates/subsets ?
Is your URL natural?
• URL Design is about searching for good names
• standard names (microformats, W3C, ...)
• dictionary, thesaurus, ...
• Find the third resource , the resource representing
relationship between resources.
• subscription, participation, ...
• Finally, ing s. belonging, tagging, ...
Searching for names
• What is it? => Meaning
• How do I get it? => Will
• Meaning shouldn t change even if query
parameters are removed.
• URL fragments should be composed of
meaningful names.
Meaning and Will in URL
http://example.com/blog/entries?page=3&lang=ja
Meaning of the Resource Will of client
• Resources are not only Database Records.
• Transactions
• Calculation Results
• Search Results
Resources ≠ Database Records
•Simple and automatic mapping looks nice
•GET/POST/PUT/DELETE
•SELECT/INSERT/UPDATE/DELETE
•It s a trap!
The Gravity of CRUD
•Why trap?
•Importance of models/tables varies.
•Core Domain Models tend to have many
more meanings and representations.
•In contrast, some tables are just
dependent tables. So they don t have
their own representations.
The Gravity of CRUD
•Don t just map 3NF tables to resources
•Some of them are too fine-grained
•N+1 Problem appears!
•Routes and Controllers should:
•Fill the gap of granularity and viewpoint
between Resources and Tables.
•Map them if and only if it is meaningful.
The Gravity of CRUD
•What do you want to do to the Resource?
•get it => GET
•create new one => POST
•modify it => UPDATE / PATCH
•delete it => DELETE
HTTP Methods
•Contents is the king and so HTTP GET is
the king.
•To make Resources:
•new Resource with new URL => POST
•URL is known/given => PUT
•If in doubt, use POST
HTTP Methods
•Status codes regularly used
•200, 201, 204
•301, 303, 307, (304)
•400, 404, 409, (401, 403, 422 (rails))
•500
•Client is wrong => 4xx
•Server is wrong => 5xx
HTTP Status Code
•Mapping Errors to 4xx or 5xx
•Models just raise Errors
•Rails maps them
•Want to hide resources => use 404
HTTP Status Code
•Should contain URL or URL
creator(forms)
•No dead-ends
•If you want to construct GET query
parameters
•use forms
•forms are not only for POST
requests
Representation
•Content Negotiation
•use Accept, Accept-Language
•Better to include representation
formats in URL (fragments,
extensions)
•more better to include languages
(ja,en,...) in URL
Representation
•Don t concat strings to create URL on
the client side!
•Client shouldn t know how to
construct URLs
•use URI-Templates
•http://tools.ietf.org/html/rfc6570
Representation
•Client can only change its
application status by
following links (or submitting
forms) in representations
served by servers
For the Connectedess
•Services should not enforce clients to
construct URL
•Services should not expect clients to
construct URL
•Services should serve representations
with links(forms) for next application
state transitions
For the Connectedess
References
tl;dr:
REST is
infection
(Use it, love it, but think carefully.)
Thanks!
http://lumberjaph.net/graph/2010/03/25/github-explorer.html

More Related Content

What's hot

flickr's architecture & php
flickr's architecture & php flickr's architecture & php
flickr's architecture & php coolpics
 
Austin Day of Rest - Introduction
Austin Day of Rest - IntroductionAustin Day of Rest - Introduction
Austin Day of Rest - IntroductionHandsOnWP.com
 
Ebook Accessibility: Why, How, and What For - ebookcraft 2016 - Laura Brady
Ebook Accessibility: Why, How, and What For - ebookcraft 2016 - Laura BradyEbook Accessibility: Why, How, and What For - ebookcraft 2016 - Laura Brady
Ebook Accessibility: Why, How, and What For - ebookcraft 2016 - Laura BradyBookNet Canada
 
Creating Truly RESTful APIs
Creating Truly RESTful APIsCreating Truly RESTful APIs
Creating Truly RESTful APIsDomenic Denicola
 
RESTful Web Services
RESTful Web ServicesRESTful Web Services
RESTful Web ServicesGreg Hines
 
On Again; Off Again - Benjamin Young - ebookcraft 2017
On Again; Off Again - Benjamin Young - ebookcraft 2017On Again; Off Again - Benjamin Young - ebookcraft 2017
On Again; Off Again - Benjamin Young - ebookcraft 2017BookNet Canada
 
You Want to Go XML-First: Now What? Building an In-House XML-First Workflow -...
You Want to Go XML-First: Now What? Building an In-House XML-First Workflow -...You Want to Go XML-First: Now What? Building an In-House XML-First Workflow -...
You Want to Go XML-First: Now What? Building an In-House XML-First Workflow -...BookNet Canada
 
Library Mashups & APIs
Library Mashups & APIsLibrary Mashups & APIs
Library Mashups & APIslibrarywebchic
 
Front End Web Development Basics
Front End Web Development BasicsFront End Web Development Basics
Front End Web Development BasicsTahir Shahzad
 
In the Trenches with Accessible EPUB - Charles LaPierre - ebookcraft 2017
In the Trenches with Accessible EPUB - Charles LaPierre - ebookcraft 2017In the Trenches with Accessible EPUB - Charles LaPierre - ebookcraft 2017
In the Trenches with Accessible EPUB - Charles LaPierre - ebookcraft 2017BookNet Canada
 
Building Beautiful REST APIs in ASP.NET Core
Building Beautiful REST APIs in ASP.NET CoreBuilding Beautiful REST APIs in ASP.NET Core
Building Beautiful REST APIs in ASP.NET CoreNate Barbettini
 
From Open Annotations to W3C Web Annotations (and the impact on IIIF Present...
From Open Annotations to W3C Web Annotations (and the impact on IIIF Present...From Open Annotations to W3C Web Annotations (and the impact on IIIF Present...
From Open Annotations to W3C Web Annotations (and the impact on IIIF Present...Simeon Warner
 
3 Hacks to Improve WordPress Performance
3 Hacks to Improve WordPress Performance3 Hacks to Improve WordPress Performance
3 Hacks to Improve WordPress PerformanceRF Studio
 
Hacking the Google Snippet - Digpen 7 workshop
Hacking the Google Snippet - Digpen 7 workshopHacking the Google Snippet - Digpen 7 workshop
Hacking the Google Snippet - Digpen 7 workshopIan Macfarlane
 
Parsing strange v4
Parsing strange v4Parsing strange v4
Parsing strange v4Hal Stern
 
The Ebook Developer's Toolbox - ebookcraft 2016 - Sanders Kleinfeld
The Ebook Developer's Toolbox - ebookcraft 2016 - Sanders Kleinfeld The Ebook Developer's Toolbox - ebookcraft 2016 - Sanders Kleinfeld
The Ebook Developer's Toolbox - ebookcraft 2016 - Sanders Kleinfeld BookNet Canada
 
Harnessing Free Content with Web Service APIs
Harnessing Free Content with Web Service APIsHarnessing Free Content with Web Service APIs
Harnessing Free Content with Web Service APIsALATechSource
 
JSON API: Não reinvente a roda
JSON API: Não reinvente a rodaJSON API: Não reinvente a roda
JSON API: Não reinvente a rodaPedro Cavalheiro
 

What's hot (20)

flickr's architecture & php
flickr's architecture & php flickr's architecture & php
flickr's architecture & php
 
Austin Day of Rest - Introduction
Austin Day of Rest - IntroductionAustin Day of Rest - Introduction
Austin Day of Rest - Introduction
 
Ebook Accessibility: Why, How, and What For - ebookcraft 2016 - Laura Brady
Ebook Accessibility: Why, How, and What For - ebookcraft 2016 - Laura BradyEbook Accessibility: Why, How, and What For - ebookcraft 2016 - Laura Brady
Ebook Accessibility: Why, How, and What For - ebookcraft 2016 - Laura Brady
 
Creating Truly RESTful APIs
Creating Truly RESTful APIsCreating Truly RESTful APIs
Creating Truly RESTful APIs
 
RESTful Web Services
RESTful Web ServicesRESTful Web Services
RESTful Web Services
 
On Again; Off Again - Benjamin Young - ebookcraft 2017
On Again; Off Again - Benjamin Young - ebookcraft 2017On Again; Off Again - Benjamin Young - ebookcraft 2017
On Again; Off Again - Benjamin Young - ebookcraft 2017
 
You Want to Go XML-First: Now What? Building an In-House XML-First Workflow -...
You Want to Go XML-First: Now What? Building an In-House XML-First Workflow -...You Want to Go XML-First: Now What? Building an In-House XML-First Workflow -...
You Want to Go XML-First: Now What? Building an In-House XML-First Workflow -...
 
Library Mashups & APIs
Library Mashups & APIsLibrary Mashups & APIs
Library Mashups & APIs
 
Front End Web Development Basics
Front End Web Development BasicsFront End Web Development Basics
Front End Web Development Basics
 
In the Trenches with Accessible EPUB - Charles LaPierre - ebookcraft 2017
In the Trenches with Accessible EPUB - Charles LaPierre - ebookcraft 2017In the Trenches with Accessible EPUB - Charles LaPierre - ebookcraft 2017
In the Trenches with Accessible EPUB - Charles LaPierre - ebookcraft 2017
 
Building Beautiful REST APIs in ASP.NET Core
Building Beautiful REST APIs in ASP.NET CoreBuilding Beautiful REST APIs in ASP.NET Core
Building Beautiful REST APIs in ASP.NET Core
 
From Open Annotations to W3C Web Annotations (and the impact on IIIF Present...
From Open Annotations to W3C Web Annotations (and the impact on IIIF Present...From Open Annotations to W3C Web Annotations (and the impact on IIIF Present...
From Open Annotations to W3C Web Annotations (and the impact on IIIF Present...
 
3 Hacks to Improve WordPress Performance
3 Hacks to Improve WordPress Performance3 Hacks to Improve WordPress Performance
3 Hacks to Improve WordPress Performance
 
Hacking the Google Snippet - Digpen 7 workshop
Hacking the Google Snippet - Digpen 7 workshopHacking the Google Snippet - Digpen 7 workshop
Hacking the Google Snippet - Digpen 7 workshop
 
Parsing strange v4
Parsing strange v4Parsing strange v4
Parsing strange v4
 
The Ebook Developer's Toolbox - ebookcraft 2016 - Sanders Kleinfeld
The Ebook Developer's Toolbox - ebookcraft 2016 - Sanders Kleinfeld The Ebook Developer's Toolbox - ebookcraft 2016 - Sanders Kleinfeld
The Ebook Developer's Toolbox - ebookcraft 2016 - Sanders Kleinfeld
 
Php reports sumit
Php reports sumitPhp reports sumit
Php reports sumit
 
Harnessing Free Content with Web Service APIs
Harnessing Free Content with Web Service APIsHarnessing Free Content with Web Service APIs
Harnessing Free Content with Web Service APIs
 
JSON API: Não reinvente a roda
JSON API: Não reinvente a rodaJSON API: Não reinvente a roda
JSON API: Não reinvente a roda
 
Why Django
Why DjangoWhy Django
Why Django
 

Viewers also liked

OSS活動の活発さと評価の関係について
OSS活動の活発さと評価の関係についてOSS活動の活発さと評価の関係について
OSS活動の活発さと評価の関係についてTakuto Wada
 
power-assert in JavaScript
power-assert in JavaScriptpower-assert in JavaScript
power-assert in JavaScriptTakuto Wada
 
私にとってのテスト
私にとってのテスト私にとってのテスト
私にとってのテストTakuto Wada
 
ペアプログラミング ホントのところ
ペアプログラミング ホントのところペアプログラミング ホントのところ
ペアプログラミング ホントのところTakuto Wada
 
TDD のこころ @ OSH2014
TDD のこころ @ OSH2014TDD のこころ @ OSH2014
TDD のこころ @ OSH2014Takuto Wada
 
RESTful Web アプリの設計レビューの話
RESTful Web アプリの設計レビューの話RESTful Web アプリの設計レビューの話
RESTful Web アプリの設計レビューの話Takuto Wada
 
組織にテストを書く文化を根付かせる戦略と戦術
組織にテストを書く文化を根付かせる戦略と戦術組織にテストを書く文化を根付かせる戦略と戦術
組織にテストを書く文化を根付かせる戦略と戦術Takuto Wada
 

Viewers also liked (7)

OSS活動の活発さと評価の関係について
OSS活動の活発さと評価の関係についてOSS活動の活発さと評価の関係について
OSS活動の活発さと評価の関係について
 
power-assert in JavaScript
power-assert in JavaScriptpower-assert in JavaScript
power-assert in JavaScript
 
私にとってのテスト
私にとってのテスト私にとってのテスト
私にとってのテスト
 
ペアプログラミング ホントのところ
ペアプログラミング ホントのところペアプログラミング ホントのところ
ペアプログラミング ホントのところ
 
TDD のこころ @ OSH2014
TDD のこころ @ OSH2014TDD のこころ @ OSH2014
TDD のこころ @ OSH2014
 
RESTful Web アプリの設計レビューの話
RESTful Web アプリの設計レビューの話RESTful Web アプリの設計レビューの話
RESTful Web アプリの設計レビューの話
 
組織にテストを書く文化を根付かせる戦略と戦術
組織にテストを書く文化を根付かせる戦略と戦術組織にテストを書く文化を根付かせる戦略と戦術
組織にテストを書く文化を根付かせる戦略と戦術
 

Similar to Reviewing RESTful Web Apps

Crossref LIVE UK Online
Crossref LIVE UK OnlineCrossref LIVE UK Online
Crossref LIVE UK OnlineCrossref
 
Why do they call it Linked Data when they want to say...?
Why do they call it Linked Data when they want to say...?Why do they call it Linked Data when they want to say...?
Why do they call it Linked Data when they want to say...?Oscar Corcho
 
Crossref LIVE US Online
Crossref LIVE US OnlineCrossref LIVE US Online
Crossref LIVE US OnlineCrossref
 
Open Source Search Tools for www2010 conferencesourcesearchtoolswww20100426dA...
Open Source Search Tools for www2010 conferencesourcesearchtoolswww20100426dA...Open Source Search Tools for www2010 conferencesourcesearchtoolswww20100426dA...
Open Source Search Tools for www2010 conferencesourcesearchtoolswww20100426dA...Ted Drake
 
Crossref Content Registration - LIVE Mumbai
Crossref Content Registration - LIVE MumbaiCrossref Content Registration - LIVE Mumbai
Crossref Content Registration - LIVE MumbaiCrossref
 
Essentials for the SharePoint Power User - SPTechCon San Francisco 2016
Essentials for the SharePoint Power User - SPTechCon San Francisco 2016Essentials for the SharePoint Power User - SPTechCon San Francisco 2016
Essentials for the SharePoint Power User - SPTechCon San Francisco 2016Drew Madelung
 
Essentials for the SharePoint Power User - SharePoint Engage Raleigh 2017
Essentials for the SharePoint Power User - SharePoint Engage Raleigh 2017Essentials for the SharePoint Power User - SharePoint Engage Raleigh 2017
Essentials for the SharePoint Power User - SharePoint Engage Raleigh 2017Drew Madelung
 
Content Registration at Crossref - LIVE Kuala Lumpur
Content Registration at Crossref - LIVE Kuala LumpurContent Registration at Crossref - LIVE Kuala Lumpur
Content Registration at Crossref - LIVE Kuala LumpurCrossref
 
Content Registration - Crossref LIVE Hannover
Content Registration - Crossref LIVE HannoverContent Registration - Crossref LIVE Hannover
Content Registration - Crossref LIVE HannoverCrossref
 
Metadata, Open Access and More: Crossref presentation
Metadata, Open Access and More: Crossref presentationMetadata, Open Access and More: Crossref presentation
Metadata, Open Access and More: Crossref presentationCrossref
 
How to build a data dictionary
How to build a data dictionaryHow to build a data dictionary
How to build a data dictionaryPiotr Kononow
 
Creating web applications with LODSPeaKr
Creating web applications with LODSPeaKrCreating web applications with LODSPeaKr
Creating web applications with LODSPeaKrAlvaro Graves
 
Working with Crossref and registering content
Working with Crossref and registering contentWorking with Crossref and registering content
Working with Crossref and registering contentCrossref
 
Pragmatic REST APIs
Pragmatic REST APIsPragmatic REST APIs
Pragmatic REST APIsamesar0
 
Crossref LIVE Indonesia: Content Registration at Crossref, CRLIVE-ID 14 July ...
Crossref LIVE Indonesia: Content Registration at Crossref, CRLIVE-ID 14 July ...Crossref LIVE Indonesia: Content Registration at Crossref, CRLIVE-ID 14 July ...
Crossref LIVE Indonesia: Content Registration at Crossref, CRLIVE-ID 14 July ...Crossref
 
DSpace 4.2 Transmission: Import/Export
DSpace 4.2 Transmission: Import/ExportDSpace 4.2 Transmission: Import/Export
DSpace 4.2 Transmission: Import/ExportDuraSpace
 
OpenTravel Advisory Forum 2012 REST XML Resources
OpenTravel Advisory Forum 2012 REST XML ResourcesOpenTravel Advisory Forum 2012 REST XML Resources
OpenTravel Advisory Forum 2012 REST XML ResourcesOpenTravel Alliance
 
Solr Recipes Workshop
Solr Recipes WorkshopSolr Recipes Workshop
Solr Recipes WorkshopErik Hatcher
 

Similar to Reviewing RESTful Web Apps (20)

Crossref LIVE UK Online
Crossref LIVE UK OnlineCrossref LIVE UK Online
Crossref LIVE UK Online
 
Why do they call it Linked Data when they want to say...?
Why do they call it Linked Data when they want to say...?Why do they call it Linked Data when they want to say...?
Why do they call it Linked Data when they want to say...?
 
Crossref LIVE US Online
Crossref LIVE US OnlineCrossref LIVE US Online
Crossref LIVE US Online
 
Open Source Search Tools for www2010 conferencesourcesearchtoolswww20100426dA...
Open Source Search Tools for www2010 conferencesourcesearchtoolswww20100426dA...Open Source Search Tools for www2010 conferencesourcesearchtoolswww20100426dA...
Open Source Search Tools for www2010 conferencesourcesearchtoolswww20100426dA...
 
Crossref Content Registration - LIVE Mumbai
Crossref Content Registration - LIVE MumbaiCrossref Content Registration - LIVE Mumbai
Crossref Content Registration - LIVE Mumbai
 
Essentials for the SharePoint Power User - SPTechCon San Francisco 2016
Essentials for the SharePoint Power User - SPTechCon San Francisco 2016Essentials for the SharePoint Power User - SPTechCon San Francisco 2016
Essentials for the SharePoint Power User - SPTechCon San Francisco 2016
 
Essentials for the SharePoint Power User - SharePoint Engage Raleigh 2017
Essentials for the SharePoint Power User - SharePoint Engage Raleigh 2017Essentials for the SharePoint Power User - SharePoint Engage Raleigh 2017
Essentials for the SharePoint Power User - SharePoint Engage Raleigh 2017
 
Content Registration at Crossref - LIVE Kuala Lumpur
Content Registration at Crossref - LIVE Kuala LumpurContent Registration at Crossref - LIVE Kuala Lumpur
Content Registration at Crossref - LIVE Kuala Lumpur
 
Content Registration - Crossref LIVE Hannover
Content Registration - Crossref LIVE HannoverContent Registration - Crossref LIVE Hannover
Content Registration - Crossref LIVE Hannover
 
HDP Next: Governance
HDP Next: GovernanceHDP Next: Governance
HDP Next: Governance
 
Metadata, Open Access and More: Crossref presentation
Metadata, Open Access and More: Crossref presentationMetadata, Open Access and More: Crossref presentation
Metadata, Open Access and More: Crossref presentation
 
How to build a data dictionary
How to build a data dictionaryHow to build a data dictionary
How to build a data dictionary
 
Creating web applications with LODSPeaKr
Creating web applications with LODSPeaKrCreating web applications with LODSPeaKr
Creating web applications with LODSPeaKr
 
APA ITU DOI?
APA ITU DOI?APA ITU DOI?
APA ITU DOI?
 
Working with Crossref and registering content
Working with Crossref and registering contentWorking with Crossref and registering content
Working with Crossref and registering content
 
Pragmatic REST APIs
Pragmatic REST APIsPragmatic REST APIs
Pragmatic REST APIs
 
Crossref LIVE Indonesia: Content Registration at Crossref, CRLIVE-ID 14 July ...
Crossref LIVE Indonesia: Content Registration at Crossref, CRLIVE-ID 14 July ...Crossref LIVE Indonesia: Content Registration at Crossref, CRLIVE-ID 14 July ...
Crossref LIVE Indonesia: Content Registration at Crossref, CRLIVE-ID 14 July ...
 
DSpace 4.2 Transmission: Import/Export
DSpace 4.2 Transmission: Import/ExportDSpace 4.2 Transmission: Import/Export
DSpace 4.2 Transmission: Import/Export
 
OpenTravel Advisory Forum 2012 REST XML Resources
OpenTravel Advisory Forum 2012 REST XML ResourcesOpenTravel Advisory Forum 2012 REST XML Resources
OpenTravel Advisory Forum 2012 REST XML Resources
 
Solr Recipes Workshop
Solr Recipes WorkshopSolr Recipes Workshop
Solr Recipes Workshop
 

More from Takuto Wada

unassert - encourage reliable programming by writing assertions in production
unassert - encourage reliable programming by writing assertions in productionunassert - encourage reliable programming by writing assertions in production
unassert - encourage reliable programming by writing assertions in productionTakuto Wada
 
OSS についてあれこれ
OSS についてあれこれOSS についてあれこれ
OSS についてあれこれTakuto Wada
 
SQLアンチパターン 幻の第26章「とりあえず削除フラグ」
SQLアンチパターン 幻の第26章「とりあえず削除フラグ」SQLアンチパターン 幻の第26章「とりあえず削除フラグ」
SQLアンチパターン 幻の第26章「とりあえず削除フラグ」Takuto Wada
 
power-assert, mechanism and philosophy
power-assert, mechanism and philosophypower-assert, mechanism and philosophy
power-assert, mechanism and philosophyTakuto Wada
 
アジャイルサムライの次に読む技術書
アジャイルサムライの次に読む技術書アジャイルサムライの次に読む技術書
アジャイルサムライの次に読む技術書Takuto Wada
 
Test Yourself - テストを書くと何がどう変わるか
Test Yourself - テストを書くと何がどう変わるかTest Yourself - テストを書くと何がどう変わるか
Test Yourself - テストを書くと何がどう変わるかTakuto Wada
 
テスト用ライブラリ power-assert
テスト用ライブラリ power-assertテスト用ライブラリ power-assert
テスト用ライブラリ power-assertTakuto Wada
 
テストを書く文化を育てる戦略と戦術
テストを書く文化を育てる戦略と戦術テストを書く文化を育てる戦略と戦術
テストを書く文化を育てる戦略と戦術Takuto Wada
 
SQLアンチパターン - 開発者を待ち受ける25の落とし穴 (拡大版)
SQLアンチパターン - 開発者を待ち受ける25の落とし穴 (拡大版)SQLアンチパターン - 開発者を待ち受ける25の落とし穴 (拡大版)
SQLアンチパターン - 開発者を待ち受ける25の落とし穴 (拡大版)Takuto Wada
 
SQLアンチパターン - 開発者を待ち受ける25の落とし穴
SQLアンチパターン - 開発者を待ち受ける25の落とし穴SQLアンチパターン - 開発者を待ち受ける25の落とし穴
SQLアンチパターン - 開発者を待ち受ける25の落とし穴Takuto Wada
 
愛せないコードを書くには人生はあまりにも短い
愛せないコードを書くには人生はあまりにも短い愛せないコードを書くには人生はあまりにも短い
愛せないコードを書くには人生はあまりにも短いTakuto Wada
 
例外設計における大罪
例外設計における大罪例外設計における大罪
例外設計における大罪Takuto Wada
 
TDDBC Fukuoka Day1
TDDBC Fukuoka Day1TDDBC Fukuoka Day1
TDDBC Fukuoka Day1Takuto Wada
 
js テスト放浪記
js テスト放浪記js テスト放浪記
js テスト放浪記Takuto Wada
 
xUTP Chapter19 (2). Testcase Class
xUTP Chapter19 (2). Testcase ClassxUTP Chapter19 (2). Testcase Class
xUTP Chapter19 (2). Testcase ClassTakuto Wada
 
xUTP Chapter26. Dependency Injection
xUTP Chapter26. Dependency InjectionxUTP Chapter26. Dependency Injection
xUTP Chapter26. Dependency InjectionTakuto Wada
 
xUTP Chapter27 Generated Value
xUTP Chapter27 Generated ValuexUTP Chapter27 Generated Value
xUTP Chapter27 Generated ValueTakuto Wada
 
The only one big thing every programmer should know
The only one big thing every programmer should knowThe only one big thing every programmer should know
The only one big thing every programmer should knowTakuto Wada
 

More from Takuto Wada (20)

unassert - encourage reliable programming by writing assertions in production
unassert - encourage reliable programming by writing assertions in productionunassert - encourage reliable programming by writing assertions in production
unassert - encourage reliable programming by writing assertions in production
 
OSS についてあれこれ
OSS についてあれこれOSS についてあれこれ
OSS についてあれこれ
 
SQLアンチパターン 幻の第26章「とりあえず削除フラグ」
SQLアンチパターン 幻の第26章「とりあえず削除フラグ」SQLアンチパターン 幻の第26章「とりあえず削除フラグ」
SQLアンチパターン 幻の第26章「とりあえず削除フラグ」
 
power-assert, mechanism and philosophy
power-assert, mechanism and philosophypower-assert, mechanism and philosophy
power-assert, mechanism and philosophy
 
アジャイルサムライの次に読む技術書
アジャイルサムライの次に読む技術書アジャイルサムライの次に読む技術書
アジャイルサムライの次に読む技術書
 
Test Yourself - テストを書くと何がどう変わるか
Test Yourself - テストを書くと何がどう変わるかTest Yourself - テストを書くと何がどう変わるか
Test Yourself - テストを書くと何がどう変わるか
 
テスト用ライブラリ power-assert
テスト用ライブラリ power-assertテスト用ライブラリ power-assert
テスト用ライブラリ power-assert
 
テストを書く文化を育てる戦略と戦術
テストを書く文化を育てる戦略と戦術テストを書く文化を育てる戦略と戦術
テストを書く文化を育てる戦略と戦術
 
SQLアンチパターン - 開発者を待ち受ける25の落とし穴 (拡大版)
SQLアンチパターン - 開発者を待ち受ける25の落とし穴 (拡大版)SQLアンチパターン - 開発者を待ち受ける25の落とし穴 (拡大版)
SQLアンチパターン - 開発者を待ち受ける25の落とし穴 (拡大版)
 
SQLアンチパターン - 開発者を待ち受ける25の落とし穴
SQLアンチパターン - 開発者を待ち受ける25の落とし穴SQLアンチパターン - 開発者を待ち受ける25の落とし穴
SQLアンチパターン - 開発者を待ち受ける25の落とし穴
 
愛せないコードを書くには人生はあまりにも短い
愛せないコードを書くには人生はあまりにも短い愛せないコードを書くには人生はあまりにも短い
愛せないコードを書くには人生はあまりにも短い
 
例外設計における大罪
例外設計における大罪例外設計における大罪
例外設計における大罪
 
TDDBC お題
TDDBC お題TDDBC お題
TDDBC お題
 
DevLOVE DDDBC
DevLOVE DDDBCDevLOVE DDDBC
DevLOVE DDDBC
 
TDDBC Fukuoka Day1
TDDBC Fukuoka Day1TDDBC Fukuoka Day1
TDDBC Fukuoka Day1
 
js テスト放浪記
js テスト放浪記js テスト放浪記
js テスト放浪記
 
xUTP Chapter19 (2). Testcase Class
xUTP Chapter19 (2). Testcase ClassxUTP Chapter19 (2). Testcase Class
xUTP Chapter19 (2). Testcase Class
 
xUTP Chapter26. Dependency Injection
xUTP Chapter26. Dependency InjectionxUTP Chapter26. Dependency Injection
xUTP Chapter26. Dependency Injection
 
xUTP Chapter27 Generated Value
xUTP Chapter27 Generated ValuexUTP Chapter27 Generated Value
xUTP Chapter27 Generated Value
 
The only one big thing every programmer should know
The only one big thing every programmer should knowThe only one big thing every programmer should know
The only one big thing every programmer should know
 

Recently uploaded

DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 

Recently uploaded (20)

DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 

Reviewing RESTful Web Apps

  • 1. Reviewing RESTful Web Apps Takuto Wada (a.k.a id:t-wada or @t_wada) Apr 12, 2014 @ RESTful Meetup
  • 3. tl;dr: REST is infection (Use it, love it, but think carefully.)
  • 4. •WEB+DB PRESS vol.32 •Discussion around Hatena-Bookmark •RubyKaigi 2006 Keynote by DHH •WEB+DB PRESS vol.38 •RESTful Web Service •RESTful Web APIs REST and me (input)
  • 5. •Java implementations (S2REST) •WEB+DB PRESS vol.42 Experiencing REST world with Restlet • Practical REST talk series by gihyo • #restwebtech book talk session REST and me (output)
  • 6. •Large Rails Project •+1000 routes •Tools for reviewing •White board •Chat (IRC, Skype, ...) •Wiki •diff Target Project
  • 7. 1. Figure out the data set 2. Split the data set into resources For each kind of resource: 3. Name the resources with URIs 4. Expose a subset of the uniform interface (GET/POST/PUT/DELETE) 5. Design the representation(s) accepted from the client 6. Design the representation(s) served to the client 7. Integrate this resource into existing resources, using hypermedia links and forms (Connectedness matters) 8. Consider the typical course of events: what s supposed to happen? 9. Consider error conditions: what might go wrong? Turning Requirements into Resources
  • 8. •URL Design (verb, structure, query params) •fighting with the gravity of CRUD •HTTP method •HTTP status code •Representation •MECE of information •Connectedness Review point
  • 9. Bad GET http://example.com/blog/getEntries Good GET http://example.com/blog/entries Bad POST http://example.com/blog/entries/add Good POST http://example.com/blog/entries Bad POST http://example.com/blog/entries/30/delete Good DELETE http://example.com/blog/entries/30 Do not include verbs in URL
  • 10. •/add, /delete, /update => Bad •/edit => it depends (convention matters) •Trying to use nouns •/confirm -> /confirmation •When the form of noun and verb are the same => it depends Do not include verbs in URL
  • 11. • Tumblr s Bizarre URL => Too Bad • http://www.tumblr.com/show/everything/by/me • Reads like spoken language doesn t matter • example.com/files/copy/:src/:dest => Bad • destination is not subordinated to source • Are they natural subordinates/subsets ? Is your URL natural?
  • 12. • URL Design is about searching for good names • standard names (microformats, W3C, ...) • dictionary, thesaurus, ... • Find the third resource , the resource representing relationship between resources. • subscription, participation, ... • Finally, ing s. belonging, tagging, ... Searching for names
  • 13. • What is it? => Meaning • How do I get it? => Will • Meaning shouldn t change even if query parameters are removed. • URL fragments should be composed of meaningful names. Meaning and Will in URL http://example.com/blog/entries?page=3&lang=ja Meaning of the Resource Will of client
  • 14. • Resources are not only Database Records. • Transactions • Calculation Results • Search Results Resources ≠ Database Records
  • 15. •Simple and automatic mapping looks nice •GET/POST/PUT/DELETE •SELECT/INSERT/UPDATE/DELETE •It s a trap! The Gravity of CRUD
  • 16. •Why trap? •Importance of models/tables varies. •Core Domain Models tend to have many more meanings and representations. •In contrast, some tables are just dependent tables. So they don t have their own representations. The Gravity of CRUD
  • 17. •Don t just map 3NF tables to resources •Some of them are too fine-grained •N+1 Problem appears! •Routes and Controllers should: •Fill the gap of granularity and viewpoint between Resources and Tables. •Map them if and only if it is meaningful. The Gravity of CRUD
  • 18. •What do you want to do to the Resource? •get it => GET •create new one => POST •modify it => UPDATE / PATCH •delete it => DELETE HTTP Methods
  • 19. •Contents is the king and so HTTP GET is the king. •To make Resources: •new Resource with new URL => POST •URL is known/given => PUT •If in doubt, use POST HTTP Methods
  • 20. •Status codes regularly used •200, 201, 204 •301, 303, 307, (304) •400, 404, 409, (401, 403, 422 (rails)) •500 •Client is wrong => 4xx •Server is wrong => 5xx HTTP Status Code
  • 21. •Mapping Errors to 4xx or 5xx •Models just raise Errors •Rails maps them •Want to hide resources => use 404 HTTP Status Code
  • 22. •Should contain URL or URL creator(forms) •No dead-ends •If you want to construct GET query parameters •use forms •forms are not only for POST requests Representation
  • 23. •Content Negotiation •use Accept, Accept-Language •Better to include representation formats in URL (fragments, extensions) •more better to include languages (ja,en,...) in URL Representation
  • 24. •Don t concat strings to create URL on the client side! •Client shouldn t know how to construct URLs •use URI-Templates •http://tools.ietf.org/html/rfc6570 Representation
  • 25. •Client can only change its application status by following links (or submitting forms) in representations served by servers For the Connectedess
  • 26. •Services should not enforce clients to construct URL •Services should not expect clients to construct URL •Services should serve representations with links(forms) for next application state transitions For the Connectedess
  • 28. tl;dr: REST is infection (Use it, love it, but think carefully.)