SlideShare a Scribd company logo
API – Developing for developers
Joy George K
Architect
www.joymononline.in
http://joymonscode.blogspot.com
API - D4D – Important
When in doubt leave it out
API - D4D - Agenda
• Developing for developers v/s developing for users
• What is API
• Characteristics of best API
• Naming philosophy
• Usability
• Consistency
• Versioning
• Error handling
• Documentation, quick start examples
• Limitations / Compromises
• Performance
• Evangelism
• Conclusion
API - D4D v/s D4U
Backward
compatible
API - D4D v/s D4U
API - D4D v/s D4U
API - D4D v/s D4U
• Similarities
• Can’t predict behavior
• Differences
• Developers are same / more skilled than you.
• Chances of misuse
• Developers can think internals more than a user think.
• Applications can be patched easily but patch to developers require more effort @ their side
• DX - Developer experience
API - D4D – What is an API
• Definition
• Boundary
• Interface
• Types
• Class / methods
• SOA
• Who writes API
• Every developer
API - D4D – What is an API
System
Component B
Component A
API
API - D4D – What is an API
Primary
System
Third
party
System
API
API - D4D – Naming Philosophy
• Use same naming patterns /philosophy
• QueueMsg(),RequeueMessage() & Message_Dequeue()
• GetCustomerById(int id) & GetEmployee(int id) –
• Use similar methods to do logically similar operations
• Button.ChangeSize(size) & TextBox.Size = size
• Same meaning throughout the platform
• GetCustomerById(int id) & FetchEmployeeById(int id)
• Button.Draw & GridPainter.Paint(grid)
• Honor logical parameter order.
• FileCopy(source,dest) & StringCopy(dest,source)
API - D4D - Usability
• Self learning / discoverable
• Avoid short names
• Indicate units in parameter names – timeoutInSeconds parameter instead of just timeout
• Avoid overloads Eg:Prefer GetById(int id) & GetByName over Get(int id) and Get(string name)
• Limit method parameters to 3.
• Try to avoid same type parameters repeating more than twice
• GetEmployee(“joy”,true,false,true,false)
API - D4D - Usability
• Stateless
• Use state only for entity classes .Operation classes should never have state.
• Class Employee{int empId,string name}
• Class SalaryCalculator{ decimal Calculate(employee);}
• Avoid public fields
• One method call should be independent of previous call
API - D4D - Usability
• Abstract as much as possible
• Do not expose internal details
• Use interface if there is a reason (Remember there is no IString)
• Loose coupling
• Dependency injection
API - D4D - Usability
• Walk in the shoe of other developer
• Start by creating the contract and use it before coding the implementation.
• Do not give surprise to users
• GetDocument() This method should not get the document by checking it out
• GetDocumentAfterCheckingout()
• Do not expose implementation details to users
• SaveEmployeeIntoSQLServer(employee);
• SaveEmployee(employee);
• Separate application APIs from support APIs
• IQueueService
• Queue();
• IQueueAdminService
• RequeueAllFailedRequests();
• BackupQueueDataStore();
API - D4D - Usability
No Boilerplate. This will help users to avoid copy paste
• Bad
• queue=QueueFactory.GetQueue()
• queue.Initialize()
• queue.SetName(“email”)
• queue.Insert()
• Good
• queue=QueueFactory.GetInitializedQueue(“email”)
• queue.Insert()
API - D4D - Usability
• API should not be a reason for writing bad app code
API - D4D - Usability
• Open for extension Closed for misuse
• Have only required protected methods
• Make use of the OOP concepts
• Make classes as sealed
• Use factory pattern
API - D4D - Usability
• Do not have extreme generic method eg:DoTask( TaskType, object[]params)
API - D4D - Usability
• Less but powerful methods if possible. Eg: GetSubListByFirstAndLastIndexes(first,last) instead of 2
GetFirsItemsTill() & GetLastItemsFrom()
API - D4D - Usability
• Do not deviate much from the platform and language conventions.
• Take advantage of platform & language (eg: Generics, Extension methods, async etc…)
• Do not reinvent the wheel
• Class Stack is already part of .Net framework
• Developers hate adding more and more references.
• Try to package more namespaces in same assemblies.
• Package base classes and default implementations in one dll
• Users should be able to use your API by referring one dll
• Extensions to core classes should be packaged in different dll
API - D4D – Important
When in doubt leave it out
API - D4D - Consistency
• Do what is intended and do it well
• Log what & how it happened.
• Try creating multiple sample apps
• Implementation can change but without affecting the API.
• Return zero length array or empty collection when returning arrays. Never return null
API - D4D – Versioning
• API are evolving. Not like constructing bridge
• You can add but cannot remove.
• Cannot write perfect API in first attempt.
• Gradual changes
• Think about developers and their apps in production before introducing change.
API - D4D – Error handling
• Try to fail during compilation
• Bad API
Public void Queue(object queueType) {
int typeId=int.Parse(…,queueType)
}
User code
Queue(“email”); //Compiles but fail at runtime.
• Good
Public void Queue(int queueType) {
int typeId= queueType;//No need to parse
}
Queue(10); // It wont compile if we pass string.
API - D4D – Error handling
• Never fail silently
• Make clear distinction between exception caused by user code and platform API code
• Log error - what & how it happened.
API - D4D - Documentation
• External
• Document public & Protected methods for sure
• A sample application is the best documentation
• Create quick start tutorials
• Videos which helps developers to productive in an hour.
• Document limitations.
• Internal
• Keep track of each and every decision. (Why its so?)
API - D4D - Limitations
• Aware of limitations.
• One API can’t satisfy everyone. So disappoint everyone equally.
API - D4D - Performance
• Set your own bench mark
• Think twice how your code is going to be executed in the binary world, before writing every line of
code.
• Should support scale up and down. Support horizontal scaling as well
• Support pagination via API
• GetEmployeesByName(string name, int from,int to);
• API should tell that it needs better hardware
• Via logs
API - D4D - Evangelism
• Test, Test and Test.
• Self use.
• Proud of your API.
• Socialize the existence.
• Take sessions.
• Listen to developers and open to change
• Support developer.
• Reply to mails.
• Create evangelists.
API - D4D – Important
When in doubt leave it out
API - D4D – Conclusion
• API Design is art than engineering
• No silver bullets
• Compromises are required
• Reward – “Quality improvement of the code you produce”
API – D4D – References
• http://lcsd05.cs.tamu.edu/slides/keynote.pdf
• https://www.youtube.com/watch?v=aAb7hSCtvGw
• http://www.apiacademy.co/
• http://wiki.netbeans.org/API_Design
• http://wiki.apidesign.org/wiki/Main_Page
• http://www.ibm.com/developerworks/library/ar-servdsgn1/
• http://media.wiley.com/assets/7255/37/9781118937228_custom.pdf
• https://docs.djangoproject.com/en/dev/misc/design-philosophies/
• Books
• Practical API Design
• A Practical approach to API design
• The design of everyday things
Are you ready to develop for developers ?
Q & A
Thank You

More Related Content

PDF
Designing APIs with OpenAPI Spec
PDF
Current Testing Challenges Ireland
PDF
Test driven development
PDF
Test Driven Development - Workshop
PDF
Getting Predictable - Pragmatic Approach for Mobile Development - Devday.lk ...
PDF
SauceCon19: Fashionable XCUITest for iOS App
PDF
NSTC2019: Choosing CI Friendly Mobile Automation Framework
PDF
Hack in the Box GSEC 2016 - Reverse Engineering Swift Applications
Designing APIs with OpenAPI Spec
Current Testing Challenges Ireland
Test driven development
Test Driven Development - Workshop
Getting Predictable - Pragmatic Approach for Mobile Development - Devday.lk ...
SauceCon19: Fashionable XCUITest for iOS App
NSTC2019: Choosing CI Friendly Mobile Automation Framework
Hack in the Box GSEC 2016 - Reverse Engineering Swift Applications

What's hot (20)

PDF
Full Stack Flutter Testing
PDF
Device fragmentation vs clean code
PDF
Fashionable XCUITest for iOS Apps by Shashikant Jagtap
PPTX
Ios driver presentation copy
PDF
Intro to Appcelerator Titanium - Code for Fort Lauderdale 2015
PPTX
Selenium + Specflow
PDF
Introduction to ART (Android Runtime)
PDF
Android Malware and Machine Learning
ODP
Mulesoft Raml APIs
PDF
Session on Testing Activities in Continuous Integration and Delivery as an Ex...
PDF
XCUITest Introduction: Test Automation University
PDF
Introduction to Android Studio
PPTX
Different Android Test Automation Frameworks - What Works You the Best?
PPTX
Build software like a bag of marbles, not a castle of LEGO®
PPTX
[Webinar] The Frog And The Butler: CI Pipelines For Modern DevOps
PDF
Testing Pyramid
PPTX
Coding Standard And Code Review
PPTX
Love your API with Swagger (Gluecon lightning talk)
PDF
Android Deobfuscation: Tools and Techniques
PPTX
Does The Delphi IDE Narrow You? Extend It! - ITDevConX European Delphi Confer...
Full Stack Flutter Testing
Device fragmentation vs clean code
Fashionable XCUITest for iOS Apps by Shashikant Jagtap
Ios driver presentation copy
Intro to Appcelerator Titanium - Code for Fort Lauderdale 2015
Selenium + Specflow
Introduction to ART (Android Runtime)
Android Malware and Machine Learning
Mulesoft Raml APIs
Session on Testing Activities in Continuous Integration and Delivery as an Ex...
XCUITest Introduction: Test Automation University
Introduction to Android Studio
Different Android Test Automation Frameworks - What Works You the Best?
Build software like a bag of marbles, not a castle of LEGO®
[Webinar] The Frog And The Butler: CI Pipelines For Modern DevOps
Testing Pyramid
Coding Standard And Code Review
Love your API with Swagger (Gluecon lightning talk)
Android Deobfuscation: Tools and Techniques
Does The Delphi IDE Narrow You? Extend It! - ITDevConX European Delphi Confer...
Ad

Viewers also liked (9)

PPT
Christina Brian Chloe Global08
PPT
Global Slide (Robert, Chelsea, Jasmine, Emily)
PPT
Global pd 4 SEA
ODP
Geography of southeast asia
PPTX
Geography: Southeast Asia
PPT
Southeast Asia
PPT
Southeast Asia Geography
PPTX
Pre colonial-period
PPT
PHILIPPINE LITERATURE DURING PRE-COLONIAL PERIOD
Christina Brian Chloe Global08
Global Slide (Robert, Chelsea, Jasmine, Emily)
Global pd 4 SEA
Geography of southeast asia
Geography: Southeast Asia
Southeast Asia
Southeast Asia Geography
Pre colonial-period
PHILIPPINE LITERATURE DURING PRE-COLONIAL PERIOD
Ad

Similar to API Design - developing for developers (20)

PPTX
Considerations For an API Strategy - Ronnie MItra API Architect Layer 7 Londo...
PPTX
Practices and Tools for Building Better APIs
PPTX
Framework Design Guidelines For Brussels Users Group
PPTX
Framework engineering JCO 2011
PDF
Oo aand d-overview
PPTX
Building a REST API for Longevity
PDF
Dependency Down, Flexibility Up – The Benefits of API-First Development
PDF
Architectural considerations when building an API
PPTX
How to build Sdk? Best practices
PDF
Practices and tools for building better API (JFall 2013)
PDF
Practices and tools for building better APIs
PPTX
Developers are People Too! Building a DX-Based API Strategy Ronnie Mitra, Pri...
PPTX
Applying a Developer-Centric Approach to API Design from API Architect Ronnie...
PDF
Smart Client Development
PPT
How to design effective APIs
PPTX
Pragmatic Approach to Microservices and Cell-based Architecture
PDF
Journey to APIs and Microservices: Best Practices
PPTX
Developer Friendly API Design
PPT
NEXiDA at OMG June 2009
PDF
Framework Engineering
Considerations For an API Strategy - Ronnie MItra API Architect Layer 7 Londo...
Practices and Tools for Building Better APIs
Framework Design Guidelines For Brussels Users Group
Framework engineering JCO 2011
Oo aand d-overview
Building a REST API for Longevity
Dependency Down, Flexibility Up – The Benefits of API-First Development
Architectural considerations when building an API
How to build Sdk? Best practices
Practices and tools for building better API (JFall 2013)
Practices and tools for building better APIs
Developers are People Too! Building a DX-Based API Strategy Ronnie Mitra, Pri...
Applying a Developer-Centric Approach to API Design from API Architect Ronnie...
Smart Client Development
How to design effective APIs
Pragmatic Approach to Microservices and Cell-based Architecture
Journey to APIs and Microservices: Best Practices
Developer Friendly API Design
NEXiDA at OMG June 2009
Framework Engineering

Recently uploaded (20)

PPTX
history of c programming in notes for students .pptx
PPT
Introduction Database Management System for Course Database
PPTX
L1 - Introduction to python Backend.pptx
PDF
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PDF
Understanding Forklifts - TECH EHS Solution
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PDF
AI in Product Development-omnex systems
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PPTX
Introduction to Artificial Intelligence
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
PDF
Digital Strategies for Manufacturing Companies
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PDF
PTS Company Brochure 2025 (1).pdf.......
history of c programming in notes for students .pptx
Introduction Database Management System for Course Database
L1 - Introduction to python Backend.pptx
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
Wondershare Filmora 15 Crack With Activation Key [2025
VVF-Customer-Presentation2025-Ver1.9.pptx
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Understanding Forklifts - TECH EHS Solution
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
AI in Product Development-omnex systems
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
Upgrade and Innovation Strategies for SAP ERP Customers
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
Introduction to Artificial Intelligence
2025 Textile ERP Trends: SAP, Odoo & Oracle
Digital Strategies for Manufacturing Companies
How to Choose the Right IT Partner for Your Business in Malaysia
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PTS Company Brochure 2025 (1).pdf.......

API Design - developing for developers

  • 1. API – Developing for developers Joy George K Architect www.joymononline.in http://joymonscode.blogspot.com
  • 2. API - D4D – Important When in doubt leave it out
  • 3. API - D4D - Agenda • Developing for developers v/s developing for users • What is API • Characteristics of best API • Naming philosophy • Usability • Consistency • Versioning • Error handling • Documentation, quick start examples • Limitations / Compromises • Performance • Evangelism • Conclusion
  • 4. API - D4D v/s D4U Backward compatible
  • 5. API - D4D v/s D4U
  • 6. API - D4D v/s D4U
  • 7. API - D4D v/s D4U • Similarities • Can’t predict behavior • Differences • Developers are same / more skilled than you. • Chances of misuse • Developers can think internals more than a user think. • Applications can be patched easily but patch to developers require more effort @ their side • DX - Developer experience
  • 8. API - D4D – What is an API • Definition • Boundary • Interface • Types • Class / methods • SOA • Who writes API • Every developer
  • 9. API - D4D – What is an API System Component B Component A API
  • 10. API - D4D – What is an API Primary System Third party System API
  • 11. API - D4D – Naming Philosophy • Use same naming patterns /philosophy • QueueMsg(),RequeueMessage() & Message_Dequeue() • GetCustomerById(int id) & GetEmployee(int id) – • Use similar methods to do logically similar operations • Button.ChangeSize(size) & TextBox.Size = size • Same meaning throughout the platform • GetCustomerById(int id) & FetchEmployeeById(int id) • Button.Draw & GridPainter.Paint(grid) • Honor logical parameter order. • FileCopy(source,dest) & StringCopy(dest,source)
  • 12. API - D4D - Usability • Self learning / discoverable • Avoid short names • Indicate units in parameter names – timeoutInSeconds parameter instead of just timeout • Avoid overloads Eg:Prefer GetById(int id) & GetByName over Get(int id) and Get(string name) • Limit method parameters to 3. • Try to avoid same type parameters repeating more than twice • GetEmployee(“joy”,true,false,true,false)
  • 13. API - D4D - Usability • Stateless • Use state only for entity classes .Operation classes should never have state. • Class Employee{int empId,string name} • Class SalaryCalculator{ decimal Calculate(employee);} • Avoid public fields • One method call should be independent of previous call
  • 14. API - D4D - Usability • Abstract as much as possible • Do not expose internal details • Use interface if there is a reason (Remember there is no IString) • Loose coupling • Dependency injection
  • 15. API - D4D - Usability • Walk in the shoe of other developer • Start by creating the contract and use it before coding the implementation. • Do not give surprise to users • GetDocument() This method should not get the document by checking it out • GetDocumentAfterCheckingout() • Do not expose implementation details to users • SaveEmployeeIntoSQLServer(employee); • SaveEmployee(employee); • Separate application APIs from support APIs • IQueueService • Queue(); • IQueueAdminService • RequeueAllFailedRequests(); • BackupQueueDataStore();
  • 16. API - D4D - Usability No Boilerplate. This will help users to avoid copy paste • Bad • queue=QueueFactory.GetQueue() • queue.Initialize() • queue.SetName(“email”) • queue.Insert() • Good • queue=QueueFactory.GetInitializedQueue(“email”) • queue.Insert()
  • 17. API - D4D - Usability • API should not be a reason for writing bad app code
  • 18. API - D4D - Usability • Open for extension Closed for misuse • Have only required protected methods • Make use of the OOP concepts • Make classes as sealed • Use factory pattern
  • 19. API - D4D - Usability • Do not have extreme generic method eg:DoTask( TaskType, object[]params)
  • 20. API - D4D - Usability • Less but powerful methods if possible. Eg: GetSubListByFirstAndLastIndexes(first,last) instead of 2 GetFirsItemsTill() & GetLastItemsFrom()
  • 21. API - D4D - Usability • Do not deviate much from the platform and language conventions. • Take advantage of platform & language (eg: Generics, Extension methods, async etc…) • Do not reinvent the wheel • Class Stack is already part of .Net framework • Developers hate adding more and more references. • Try to package more namespaces in same assemblies. • Package base classes and default implementations in one dll • Users should be able to use your API by referring one dll • Extensions to core classes should be packaged in different dll
  • 22. API - D4D – Important When in doubt leave it out
  • 23. API - D4D - Consistency • Do what is intended and do it well • Log what & how it happened. • Try creating multiple sample apps • Implementation can change but without affecting the API. • Return zero length array or empty collection when returning arrays. Never return null
  • 24. API - D4D – Versioning • API are evolving. Not like constructing bridge • You can add but cannot remove. • Cannot write perfect API in first attempt. • Gradual changes • Think about developers and their apps in production before introducing change.
  • 25. API - D4D – Error handling • Try to fail during compilation • Bad API Public void Queue(object queueType) { int typeId=int.Parse(…,queueType) } User code Queue(“email”); //Compiles but fail at runtime. • Good Public void Queue(int queueType) { int typeId= queueType;//No need to parse } Queue(10); // It wont compile if we pass string.
  • 26. API - D4D – Error handling • Never fail silently • Make clear distinction between exception caused by user code and platform API code • Log error - what & how it happened.
  • 27. API - D4D - Documentation • External • Document public & Protected methods for sure • A sample application is the best documentation • Create quick start tutorials • Videos which helps developers to productive in an hour. • Document limitations. • Internal • Keep track of each and every decision. (Why its so?)
  • 28. API - D4D - Limitations • Aware of limitations. • One API can’t satisfy everyone. So disappoint everyone equally.
  • 29. API - D4D - Performance • Set your own bench mark • Think twice how your code is going to be executed in the binary world, before writing every line of code. • Should support scale up and down. Support horizontal scaling as well • Support pagination via API • GetEmployeesByName(string name, int from,int to); • API should tell that it needs better hardware • Via logs
  • 30. API - D4D - Evangelism • Test, Test and Test. • Self use. • Proud of your API. • Socialize the existence. • Take sessions. • Listen to developers and open to change • Support developer. • Reply to mails. • Create evangelists.
  • 31. API - D4D – Important When in doubt leave it out
  • 32. API - D4D – Conclusion • API Design is art than engineering • No silver bullets • Compromises are required • Reward – “Quality improvement of the code you produce”
  • 33. API – D4D – References • http://lcsd05.cs.tamu.edu/slides/keynote.pdf • https://www.youtube.com/watch?v=aAb7hSCtvGw • http://www.apiacademy.co/ • http://wiki.netbeans.org/API_Design • http://wiki.apidesign.org/wiki/Main_Page • http://www.ibm.com/developerworks/library/ar-servdsgn1/ • http://media.wiley.com/assets/7255/37/9781118937228_custom.pdf • https://docs.djangoproject.com/en/dev/misc/design-philosophies/ • Books • Practical API Design • A Practical approach to API design • The design of everyday things
  • 34. Are you ready to develop for developers ? Q & A