SlideShare ist ein Scribd-Unternehmen logo
1 von 27
UK: +44 (0) 8450 571 234
US: +1 203 838 3700
Europe, Middle East & Africa: +00 971 5033 502964
Australia: +61420237512
www.fourth.com
Building Software
WebAPI Design Guide
Date: 24-Apr-2017
Alexander Goida
Presenter
Alexander Goida
Senior Software Engineer – StarChef
Knowledge Sharing facilitator – Sofia
Almost 2 years in Fourth and 14 years in IT as Software Developer
Topics for today
• Web Services overview
• RESTful service principles
• Example: Book Store inventory
• Define Domain model
• Define resources
• Adhere IT standards
• Design classes
• Testing
Web Services overview
There are no rules of architecture
for a castle in the clouds.
Web Services overview: Simplified architecture
Web Services overview: WCF protocols
WCF Services
• Supports multiple protocols
• Strong typing
• Very configurable
• Complex for heterogeneous system
• Supports GET, POST by default
Web Services overview: Web API protocols
Web API Services
• Simple
• Supports all HTTP verbs & features
• Supports MVC features
• Supports only HTTP protocol
• No strong typing
Web Services overview: Architectural styles
• Endpoint contains routine name
• Good when exposing existing routines to web
• Good when server keeps the state
• Simpler to design
• Endpoint contains resource name
• Good for new systems
• Good for stateless operations
• Good for Javascript clients
• Closer to web
RESTful service principles
There are three constants in life...
change, choice and principles.
RESTful service principles
1. Uniform Interface
2. Stateless Interactions
3. Cacheable
4. Client-Server
5. Layered System
6. Code on Demand (optional)
RESTful service principles
Level 0:
Swamp of
POX
• Plain Old XML
• XML-RPC,
SOAP
Level 1:
Resources
Level 2:
HTTP verbs
• All verbs
• HTTP Status Codes
Level 3:
Hypermedia
controls
• HATEOAS
• Dynamic discovery
of endpoints
Richardson Maturity Model
Ideal RESTful
service
Most of REST services
Example: Book Store inventory
The practice killed hedgehog who
knew how to eat cactus safely
Example: Book Store inventory
• Simple business model
• RESTful service (level 2)
• Supports
• CRUD operations
• OData queries
• Documented (Swagger)
• Versioned
• Source code at GitHub
Example: Book Store inventory
Domain Model
Bounded contexts
Resources
Service granularity
Standards
HATEOAS
Open API
OData
Versioning
Security
Basic Authentication
OAuth
Classes
SOLID
Software Patterns
Designing steps & Considerations
1 2 3 4 5
Example: Book Store inventory
• Bounded context
• Aggregation root
• Entity
• Value object
Define Domain Model
Example: Book Store inventory
• Use your Domain model
• Define “language” to your API
• Root & Dependent resources
• GET /authors
• DELETE /authors/ID
• GET /authors/ID/books
• Anti-patterns
• GET /authors/delete?id=GUID
• POST /GetPublisherDetails
• POST /author/create
Define Resources
Example: Book Store inventory
• HATEOAS - Hypermedia as the
Engine of Application State
• The essential part of the "uniform
interface"
• API is discovered dynamically
through interaction with the service
Adhere industry standards
{
"class": [ "order" ],
"properties": {
"orderNumber": 42,
"itemCount": 3,
"status": "pending"
},
"entities": [
{
"class": [ "items", "collection" ],
"rel": [ "http://x.io/rels/order-items" ],
"href": "http://api.x.io/orders/42/items"
},
{
"class": [ "info", "customer" ],
"rel": [ "http://x.io/rels/customer" ],
"properties": {
"customerId": "pj123",
"name": "Peter Joseph"
},
"links": [
{ "rel": [ "self" ], "href": "http://api.x.io/customers/pj123" }
]
}
],
"actions": [
{
"name": "add-item",
"title": "Add Item",
"method": "POST",
"href": "http://api.x.io/orders/42/items",
"type": "application/x-www-form-urlencoded",
"fields": [
{ "name": "orderNumber", "type": "hidden", "value": "42" },
{ "name": "productCode", "type": "text" },
{ "name": "quantity", "type": "number" }
]
}
],
"links": [
{ "rel": [ "self" ], "href": "http://api.x.io/orders/42" },
{ "rel": [ "previous" ], "href": "http://api.x.io/orders/41" },
{ "rel": [ "next" ], "href": "http://api.x.io/orders/43" }
]
}
{
"orderNumber": 42,
"itemCount": 3,
"status": "pending"
}
Example: Book Store inventory
• Open API Specification (Swagger 2.0)
• JSON base specification
• Language-agnostic specification of RESTful APIs
• Server proxy can be auto-generated
• Swashbuckle automates for .NET with UI
Adhere industry standards
Example: Book Store inventory
• OData – Open Data Protocol to query data in RESTful APIs
• Deal with a lot of data
• Filtering, sorting and paging
Adhere industry standards
Query Option Sample Description
$filter /authors?$filter=Name eq ‘name’
/authors?$filter=contains(Name, ‘name')
filter a collection of resources that are
addressed by a request
$orderby /authors?$orderby=Name desc request resources in asc or desc order
$select /authors?$select=Name requests a limited set of properties for
each entity
$skip & $top /authors?$skip=5
/authors?$top=5
request a limited number of records
Example: Book Store inventory
• Versioning:
• MAJOR for breaking changes
• MINOR for backwards-compatible changes
• PATCH for backwards-compatible bug fixes
• In general only MAJOR is used
Adhere industry standards
Style Sample
URL /api/v2/authors
Custom header /api/authors
Header: api-version=2
Accept header Accept: application/vnd.bookstore.v2+json
Also Possible:
• /api/foo?api-version=1.0
• /api/foo?api-version=2.0-Alpha
• /api/foo?api-version=2015-05-01.3.0
• /api/v2.0-Alpha/foo
• /api/v2015-05-01.3.0/foo
Example: Book Store inventory
• SOLID
• Use constructor for injecting
• Low coupling, High cohesion
• KISS, YAGNI, DRY
• Patterns
• Data Mapper
• Dependency Injection
• Repository
• Unit Of Work
• Anti-patterns
• Service locator
• God object
Design classes
Example: Book Store inventory
Design classes
Testing
Test less, but tests smarter
Testing
• Vision
• Defend your solution with tests
• Consider use cases of methods
• Test requirements, not everything
• The less integration tests, the better
• Unit testing
• AAA style
• Isolated tests
• Better to test through public methods
• Integration testing
• In-Memory hosting is simple
• Check routing and database
• Manual testing
• Tools Swagger UI, Postman
Glossary
• WCF
• Windows Communication Foundation, a framework for building service-oriented application software
• REST
• Representational State Transfer, the architectural style which allows clients manipulate web resources using stateless operations
• HATEOAS
• Hypermedia as the Engine of Application State, a constraint of RESTful style which allows a client to interact with a service
through hypermedia provided dynamically
• SOAP
• Simple Object Access Protocol, a protocol specification based on XML for exchanging structured information independent of
language and platforms
• RPC
• Remote Procedure Call, an inter-process communication technique in networked computing
• Named Pipes
• An inter-process communication technique within same machine
• OData
• Open Data Protocol, an open protocol which allows the creation and consumption of queryable APIs
Reading Material & Sources
1. Modern Web App Architecture (web link)
2. Chapter 21: Designing Web Applications (web link)
3. Difference between WCF and Web API and WCF REST and Web Service (web link)
4. Do you really know why you prefer REST over RPC? (web link)
5. What Is REST? (web link)
6. Richardson Maturity Model (web link)
7. API design (web link)
8. Choosing a hypermedia type for your API (web link)
9. Choosing a Transport (web link)
10. Best Practices for Designing a Pragmatic RESTful API (web link)
11. Adding Swagger to Web API project (web link)
12. Demystify Web API Versioning (web link)
13. Introduction to OData (video)
14. OData tutorial (web link)
Final questions?
Too much information?
But this is just the beginning!

Weitere ähnliche Inhalte

Was ist angesagt?

SharePoint Development in Government Environments
SharePoint Development in Government EnvironmentsSharePoint Development in Government Environments
SharePoint Development in Government EnvironmentsGunjan Datta
 
RESTFul Web API Services @ DotNetToscana
RESTFul Web API Services @ DotNetToscanaRESTFul Web API Services @ DotNetToscana
RESTFul Web API Services @ DotNetToscanaMatteo Baglini
 
Overview of Rest Service and ASP.NET WEB API
Overview of Rest Service and ASP.NET WEB APIOverview of Rest Service and ASP.NET WEB API
Overview of Rest Service and ASP.NET WEB APIPankaj Bajaj
 
Library Mashups & APIs
Library Mashups & APIsLibrary Mashups & APIs
Library Mashups & APIslibrarywebchic
 
Dropping ACID: Wrapping Your Mind Around NoSQL Databases
Dropping ACID: Wrapping Your Mind Around NoSQL DatabasesDropping ACID: Wrapping Your Mind Around NoSQL Databases
Dropping ACID: Wrapping Your Mind Around NoSQL DatabasesKyle Banerjee
 
Polyglot Persistence with MongoDB and Neo4j
Polyglot Persistence with MongoDB and Neo4jPolyglot Persistence with MongoDB and Neo4j
Polyglot Persistence with MongoDB and Neo4jCorie Pollock
 
Cloud Security Monitoring and Spark Analytics
Cloud Security Monitoring and Spark AnalyticsCloud Security Monitoring and Spark Analytics
Cloud Security Monitoring and Spark Analyticsamesar0
 
Portal and Intranets
Portal and Intranets Portal and Intranets
Portal and Intranets Redar Ismail
 
Quick start guide to java script frameworks for sharepoint apps spsbe-2015
Quick start guide to java script frameworks for sharepoint apps spsbe-2015Quick start guide to java script frameworks for sharepoint apps spsbe-2015
Quick start guide to java script frameworks for sharepoint apps spsbe-2015Sonja Madsen
 
Building RESTfull Data Services with WebAPI
Building RESTfull Data Services with WebAPIBuilding RESTfull Data Services with WebAPI
Building RESTfull Data Services with WebAPIGert Drapers
 
2018 09-03 aOS Aachen - SharePoint demystified - Thomas Vochten
2018 09-03 aOS Aachen - SharePoint demystified - Thomas Vochten2018 09-03 aOS Aachen - SharePoint demystified - Thomas Vochten
2018 09-03 aOS Aachen - SharePoint demystified - Thomas VochtenaOS Community
 
SharePoint Development in Government Environments
SharePoint Development in Government EnvironmentsSharePoint Development in Government Environments
SharePoint Development in Government EnvironmentsGunjan Datta
 
Web services soap
Web services soapWeb services soap
Web services soapKhan625
 
Share point saturday presentation 9 29-2012-2
Share point saturday presentation 9 29-2012-2Share point saturday presentation 9 29-2012-2
Share point saturday presentation 9 29-2012-2Derek Gusoff
 
Migrating from RDBMS to MongoDB
Migrating from RDBMS to MongoDBMigrating from RDBMS to MongoDB
Migrating from RDBMS to MongoDBMongoDB
 

Was ist angesagt? (20)

SharePoint Development in Government Environments
SharePoint Development in Government EnvironmentsSharePoint Development in Government Environments
SharePoint Development in Government Environments
 
RESTFul Web API Services @ DotNetToscana
RESTFul Web API Services @ DotNetToscanaRESTFul Web API Services @ DotNetToscana
RESTFul Web API Services @ DotNetToscana
 
Overview of Rest Service and ASP.NET WEB API
Overview of Rest Service and ASP.NET WEB APIOverview of Rest Service and ASP.NET WEB API
Overview of Rest Service and ASP.NET WEB API
 
Library Mashups & APIs
Library Mashups & APIsLibrary Mashups & APIs
Library Mashups & APIs
 
Dropping ACID: Wrapping Your Mind Around NoSQL Databases
Dropping ACID: Wrapping Your Mind Around NoSQL DatabasesDropping ACID: Wrapping Your Mind Around NoSQL Databases
Dropping ACID: Wrapping Your Mind Around NoSQL Databases
 
Polyglot Persistence with MongoDB and Neo4j
Polyglot Persistence with MongoDB and Neo4jPolyglot Persistence with MongoDB and Neo4j
Polyglot Persistence with MongoDB and Neo4j
 
Cloud Security Monitoring and Spark Analytics
Cloud Security Monitoring and Spark AnalyticsCloud Security Monitoring and Spark Analytics
Cloud Security Monitoring and Spark Analytics
 
Portal and Intranets
Portal and Intranets Portal and Intranets
Portal and Intranets
 
Quick start guide to java script frameworks for sharepoint apps spsbe-2015
Quick start guide to java script frameworks for sharepoint apps spsbe-2015Quick start guide to java script frameworks for sharepoint apps spsbe-2015
Quick start guide to java script frameworks for sharepoint apps spsbe-2015
 
Building RESTfull Data Services with WebAPI
Building RESTfull Data Services with WebAPIBuilding RESTfull Data Services with WebAPI
Building RESTfull Data Services with WebAPI
 
RavenDB Overview
RavenDB OverviewRavenDB Overview
RavenDB Overview
 
2018 09-03 aOS Aachen - SharePoint demystified - Thomas Vochten
2018 09-03 aOS Aachen - SharePoint demystified - Thomas Vochten2018 09-03 aOS Aachen - SharePoint demystified - Thomas Vochten
2018 09-03 aOS Aachen - SharePoint demystified - Thomas Vochten
 
SharePoint Development in Government Environments
SharePoint Development in Government EnvironmentsSharePoint Development in Government Environments
SharePoint Development in Government Environments
 
Web services soap
Web services soapWeb services soap
Web services soap
 
Share point saturday presentation 9 29-2012-2
Share point saturday presentation 9 29-2012-2Share point saturday presentation 9 29-2012-2
Share point saturday presentation 9 29-2012-2
 
Rest in flask
Rest in flaskRest in flask
Rest in flask
 
Rest assured
Rest assuredRest assured
Rest assured
 
MongoDB
MongoDBMongoDB
MongoDB
 
Intro to RavenDB
Intro to RavenDBIntro to RavenDB
Intro to RavenDB
 
Migrating from RDBMS to MongoDB
Migrating from RDBMS to MongoDBMigrating from RDBMS to MongoDB
Migrating from RDBMS to MongoDB
 

Ähnlich wie Building Software Backend (Web API)

Introduction to Restful Web Services
Introduction to Restful Web ServicesIntroduction to Restful Web Services
Introduction to Restful Web Servicesweili_at_slideshare
 
Service-Oriented Design and Implement with Rails3
Service-Oriented Design and Implement with Rails3Service-Oriented Design and Implement with Rails3
Service-Oriented Design and Implement with Rails3Wen-Tien Chang
 
Advanced Web Development in PHP - Understanding REST API
Advanced Web Development in PHP - Understanding REST APIAdvanced Web Development in PHP - Understanding REST API
Advanced Web Development in PHP - Understanding REST APIRasan Samarasinghe
 
Rest api webinar(3)
Rest api webinar(3)Rest api webinar(3)
Rest api webinar(3)WSO2
 
REST & API Management with the WSO2 ESB
REST & API Management with the WSO2 ESBREST & API Management with the WSO2 ESB
REST & API Management with the WSO2 ESBWSO2
 
REST API Recommendations
REST API RecommendationsREST API Recommendations
REST API RecommendationsJeelani Shaik
 
Overview of REST - Raihan Ullah
Overview of REST - Raihan UllahOverview of REST - Raihan Ullah
Overview of REST - Raihan UllahCefalo
 
ASP.NET Mvc 4 web api
ASP.NET Mvc 4 web apiASP.NET Mvc 4 web api
ASP.NET Mvc 4 web apiTiago Knoch
 
Global Azure 2022 - Architecting Modern Serverless APIs with Azure Functions ...
Global Azure 2022 - Architecting Modern Serverless APIs with Azure Functions ...Global Azure 2022 - Architecting Modern Serverless APIs with Azure Functions ...
Global Azure 2022 - Architecting Modern Serverless APIs with Azure Functions ...Callon Campbell
 
ARM CoAP Tutorial
ARM CoAP TutorialARM CoAP Tutorial
ARM CoAP Tutorialzdshelby
 
Documenting an API for the First Time? Quick-Start Tips for Your First API Do...
Documenting an API for the First Time? Quick-Start Tips for Your First API Do...Documenting an API for the First Time? Quick-Start Tips for Your First API Do...
Documenting an API for the First Time? Quick-Start Tips for Your First API Do...Petko Mikhailov
 
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
 
Connecting to Data from Windows Phone 8
Connecting to Data from Windows Phone 8Connecting to Data from Windows Phone 8
Connecting to Data from Windows Phone 8Woodruff Solutions LLC
 
Best Practices in Web Service Design
Best Practices in Web Service DesignBest Practices in Web Service Design
Best Practices in Web Service DesignLorna Mitchell
 
Restful风格ž„web服务架构
Restful风格ž„web服务架构Restful风格ž„web服务架构
Restful风格ž„web服务架构Benjamin Tan
 
Hypermedia for Machine APIs
Hypermedia for Machine APIsHypermedia for Machine APIs
Hypermedia for Machine APIsMichael Koster
 

Ähnlich wie Building Software Backend (Web API) (20)

Introduction to Restful Web Services
Introduction to Restful Web ServicesIntroduction to Restful Web Services
Introduction to Restful Web Services
 
Service-Oriented Design and Implement with Rails3
Service-Oriented Design and Implement with Rails3Service-Oriented Design and Implement with Rails3
Service-Oriented Design and Implement with Rails3
 
Advanced Web Development in PHP - Understanding REST API
Advanced Web Development in PHP - Understanding REST APIAdvanced Web Development in PHP - Understanding REST API
Advanced Web Development in PHP - Understanding REST API
 
Overview of java web services
Overview of java web servicesOverview of java web services
Overview of java web services
 
Rest APIs Training
Rest APIs TrainingRest APIs Training
Rest APIs Training
 
Rest api webinar(3)
Rest api webinar(3)Rest api webinar(3)
Rest api webinar(3)
 
REST & API Management with the WSO2 ESB
REST & API Management with the WSO2 ESBREST & API Management with the WSO2 ESB
REST & API Management with the WSO2 ESB
 
REST API Recommendations
REST API RecommendationsREST API Recommendations
REST API Recommendations
 
Overview of REST - Raihan Ullah
Overview of REST - Raihan UllahOverview of REST - Raihan Ullah
Overview of REST - Raihan Ullah
 
ASP.NET Mvc 4 web api
ASP.NET Mvc 4 web apiASP.NET Mvc 4 web api
ASP.NET Mvc 4 web api
 
Global Azure 2022 - Architecting Modern Serverless APIs with Azure Functions ...
Global Azure 2022 - Architecting Modern Serverless APIs with Azure Functions ...Global Azure 2022 - Architecting Modern Serverless APIs with Azure Functions ...
Global Azure 2022 - Architecting Modern Serverless APIs with Azure Functions ...
 
ARM CoAP Tutorial
ARM CoAP TutorialARM CoAP Tutorial
ARM CoAP Tutorial
 
Mini-Training: Let's have a rest
Mini-Training: Let's have a restMini-Training: Let's have a rest
Mini-Training: Let's have a rest
 
Documenting an API for the First Time? Quick-Start Tips for Your First API Do...
Documenting an API for the First Time? Quick-Start Tips for Your First API Do...Documenting an API for the First Time? Quick-Start Tips for Your First API Do...
Documenting an API for the First Time? Quick-Start Tips for Your First API Do...
 
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
 
Connecting to Data from Windows Phone 8
Connecting to Data from Windows Phone 8Connecting to Data from Windows Phone 8
Connecting to Data from Windows Phone 8
 
Web services soap rest training
Web services soap rest trainingWeb services soap rest training
Web services soap rest training
 
Best Practices in Web Service Design
Best Practices in Web Service DesignBest Practices in Web Service Design
Best Practices in Web Service Design
 
Restful风格ž„web服务架构
Restful风格ž„web服务架构Restful风格ž„web服务架构
Restful风格ž„web服务架构
 
Hypermedia for Machine APIs
Hypermedia for Machine APIsHypermedia for Machine APIs
Hypermedia for Machine APIs
 

Kürzlich hochgeladen

The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Alkin Tezuysal
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
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
 
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
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
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
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Strongerpanagenda
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesThousandEyes
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 

Kürzlich hochgeladen (20)

The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
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
 
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
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
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
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 

Building Software Backend (Web API)

  • 1. UK: +44 (0) 8450 571 234 US: +1 203 838 3700 Europe, Middle East & Africa: +00 971 5033 502964 Australia: +61420237512 www.fourth.com Building Software WebAPI Design Guide Date: 24-Apr-2017 Alexander Goida
  • 2. Presenter Alexander Goida Senior Software Engineer – StarChef Knowledge Sharing facilitator – Sofia Almost 2 years in Fourth and 14 years in IT as Software Developer
  • 3. Topics for today • Web Services overview • RESTful service principles • Example: Book Store inventory • Define Domain model • Define resources • Adhere IT standards • Design classes • Testing
  • 4. Web Services overview There are no rules of architecture for a castle in the clouds.
  • 5. Web Services overview: Simplified architecture
  • 6. Web Services overview: WCF protocols WCF Services • Supports multiple protocols • Strong typing • Very configurable • Complex for heterogeneous system • Supports GET, POST by default
  • 7. Web Services overview: Web API protocols Web API Services • Simple • Supports all HTTP verbs & features • Supports MVC features • Supports only HTTP protocol • No strong typing
  • 8. Web Services overview: Architectural styles • Endpoint contains routine name • Good when exposing existing routines to web • Good when server keeps the state • Simpler to design • Endpoint contains resource name • Good for new systems • Good for stateless operations • Good for Javascript clients • Closer to web
  • 9. RESTful service principles There are three constants in life... change, choice and principles.
  • 10. RESTful service principles 1. Uniform Interface 2. Stateless Interactions 3. Cacheable 4. Client-Server 5. Layered System 6. Code on Demand (optional)
  • 11. RESTful service principles Level 0: Swamp of POX • Plain Old XML • XML-RPC, SOAP Level 1: Resources Level 2: HTTP verbs • All verbs • HTTP Status Codes Level 3: Hypermedia controls • HATEOAS • Dynamic discovery of endpoints Richardson Maturity Model Ideal RESTful service Most of REST services
  • 12. Example: Book Store inventory The practice killed hedgehog who knew how to eat cactus safely
  • 13. Example: Book Store inventory • Simple business model • RESTful service (level 2) • Supports • CRUD operations • OData queries • Documented (Swagger) • Versioned • Source code at GitHub
  • 14. Example: Book Store inventory Domain Model Bounded contexts Resources Service granularity Standards HATEOAS Open API OData Versioning Security Basic Authentication OAuth Classes SOLID Software Patterns Designing steps & Considerations 1 2 3 4 5
  • 15. Example: Book Store inventory • Bounded context • Aggregation root • Entity • Value object Define Domain Model
  • 16. Example: Book Store inventory • Use your Domain model • Define “language” to your API • Root & Dependent resources • GET /authors • DELETE /authors/ID • GET /authors/ID/books • Anti-patterns • GET /authors/delete?id=GUID • POST /GetPublisherDetails • POST /author/create Define Resources
  • 17. Example: Book Store inventory • HATEOAS - Hypermedia as the Engine of Application State • The essential part of the "uniform interface" • API is discovered dynamically through interaction with the service Adhere industry standards { "class": [ "order" ], "properties": { "orderNumber": 42, "itemCount": 3, "status": "pending" }, "entities": [ { "class": [ "items", "collection" ], "rel": [ "http://x.io/rels/order-items" ], "href": "http://api.x.io/orders/42/items" }, { "class": [ "info", "customer" ], "rel": [ "http://x.io/rels/customer" ], "properties": { "customerId": "pj123", "name": "Peter Joseph" }, "links": [ { "rel": [ "self" ], "href": "http://api.x.io/customers/pj123" } ] } ], "actions": [ { "name": "add-item", "title": "Add Item", "method": "POST", "href": "http://api.x.io/orders/42/items", "type": "application/x-www-form-urlencoded", "fields": [ { "name": "orderNumber", "type": "hidden", "value": "42" }, { "name": "productCode", "type": "text" }, { "name": "quantity", "type": "number" } ] } ], "links": [ { "rel": [ "self" ], "href": "http://api.x.io/orders/42" }, { "rel": [ "previous" ], "href": "http://api.x.io/orders/41" }, { "rel": [ "next" ], "href": "http://api.x.io/orders/43" } ] } { "orderNumber": 42, "itemCount": 3, "status": "pending" }
  • 18. Example: Book Store inventory • Open API Specification (Swagger 2.0) • JSON base specification • Language-agnostic specification of RESTful APIs • Server proxy can be auto-generated • Swashbuckle automates for .NET with UI Adhere industry standards
  • 19. Example: Book Store inventory • OData – Open Data Protocol to query data in RESTful APIs • Deal with a lot of data • Filtering, sorting and paging Adhere industry standards Query Option Sample Description $filter /authors?$filter=Name eq ‘name’ /authors?$filter=contains(Name, ‘name') filter a collection of resources that are addressed by a request $orderby /authors?$orderby=Name desc request resources in asc or desc order $select /authors?$select=Name requests a limited set of properties for each entity $skip & $top /authors?$skip=5 /authors?$top=5 request a limited number of records
  • 20. Example: Book Store inventory • Versioning: • MAJOR for breaking changes • MINOR for backwards-compatible changes • PATCH for backwards-compatible bug fixes • In general only MAJOR is used Adhere industry standards Style Sample URL /api/v2/authors Custom header /api/authors Header: api-version=2 Accept header Accept: application/vnd.bookstore.v2+json Also Possible: • /api/foo?api-version=1.0 • /api/foo?api-version=2.0-Alpha • /api/foo?api-version=2015-05-01.3.0 • /api/v2.0-Alpha/foo • /api/v2015-05-01.3.0/foo
  • 21. Example: Book Store inventory • SOLID • Use constructor for injecting • Low coupling, High cohesion • KISS, YAGNI, DRY • Patterns • Data Mapper • Dependency Injection • Repository • Unit Of Work • Anti-patterns • Service locator • God object Design classes
  • 22. Example: Book Store inventory Design classes
  • 23. Testing Test less, but tests smarter
  • 24. Testing • Vision • Defend your solution with tests • Consider use cases of methods • Test requirements, not everything • The less integration tests, the better • Unit testing • AAA style • Isolated tests • Better to test through public methods • Integration testing • In-Memory hosting is simple • Check routing and database • Manual testing • Tools Swagger UI, Postman
  • 25. Glossary • WCF • Windows Communication Foundation, a framework for building service-oriented application software • REST • Representational State Transfer, the architectural style which allows clients manipulate web resources using stateless operations • HATEOAS • Hypermedia as the Engine of Application State, a constraint of RESTful style which allows a client to interact with a service through hypermedia provided dynamically • SOAP • Simple Object Access Protocol, a protocol specification based on XML for exchanging structured information independent of language and platforms • RPC • Remote Procedure Call, an inter-process communication technique in networked computing • Named Pipes • An inter-process communication technique within same machine • OData • Open Data Protocol, an open protocol which allows the creation and consumption of queryable APIs
  • 26. Reading Material & Sources 1. Modern Web App Architecture (web link) 2. Chapter 21: Designing Web Applications (web link) 3. Difference between WCF and Web API and WCF REST and Web Service (web link) 4. Do you really know why you prefer REST over RPC? (web link) 5. What Is REST? (web link) 6. Richardson Maturity Model (web link) 7. API design (web link) 8. Choosing a hypermedia type for your API (web link) 9. Choosing a Transport (web link) 10. Best Practices for Designing a Pragmatic RESTful API (web link) 11. Adding Swagger to Web API project (web link) 12. Demystify Web API Versioning (web link) 13. Introduction to OData (video) 14. OData tutorial (web link)
  • 27. Final questions? Too much information? But this is just the beginning!