SlideShare a Scribd company logo
public void saveAsMidi()
{
Player player = new Player();
Pattern pattern = new Pattern("A5q B5q C5q");
try {
player.saveMidi(pattern, new File("MySong.midi"));
} catch (IOException e)
{
// handle IO Exception
}
}
public void loadAndPlayMidi()
{
Player player = new Player();
try {
player.playMidiDirectly(new File("MySong.midi"));
} catch (IOException e)
{
// handle IO Exception
} catch (InvalidMidiDataException e)
{
// handle Invalid MIDI Data Exception
}
}
public void savePattern()
{
Pattern pattern = new Pattern("A5q B5q C5q");
try {
pattern.savePattern(new File("MusicString.jfugue"));
} catch (IOException e)
{
// handle IO Exception
}
}
public void loadPattern()
{
Player player = new Player();
Pattern pattern = null;
try {
pattern = Pattern.loadPattern(new File("MusicString.jfugue"));
player.play(pattern);
Golden Rules of API Design
David Koelle
davekoelle.com
July 19, 2011
Objectives
• Learn guidelines for creating a solid API
• Understand the importance of API Usability
• Consider how even the best-designed API needs to
be accompanied with clear documents and guides to
succeed
Overview
• Background and Definitions
• The Importance of API Usability
• Guidelines for API Design
• The Importance of Effective Communication in API
Usability
• Questions and Discussion
Overview
• Background and Definitions
• The Importance of API Usability
• Guidelines for API Design
• The Importance of Effective Communication in API
Usability
• Questions and Discussion
Speaker background
• David Koelle
• First computer: TI-99/4A in 2nd grade
• Graduate of Worcester Polytechnic Institute
(Massachusetts, USA)
• 14-year career spans large and small businesses and start-ups
• Three-time Java Rock Star for talks given at JavaOne
• David has developed APIs for:
• Music Programming (JFugue)
• User Interfaces
• Graphics and Animation
• Business Intelligence
• Social Network Analysis
Definitions
• An Application Programming Interface (API) is
comprised of the exposed code that other
developers use to access a program’s functionality
• Examples:
• JFugue API for music programming (Java)
• Google Maps API (JavaScript, Flash, and web services)
• API Usability is a set of guidelines for creating APIs
that others can understand and use effectively
Definitions of usability
“Usability is how easy, efficient, and pleasant
it is to use a service”
– Jacob Nielsen
“Usability is the effectiveness, efficiency, and satisfaction
with which specified users achieve specified goals
in particular environments”
– ISO-9241 (Ergonomics of Human System Interaction)
• These definitions come from the User Interface (UI)
community, but are applicable to API Design as well!
Components of API Usability
• API Usability is informed by good programming
practices and user interface design
Good
Programming
Practices
User
Interface
Design
API Usability
Components of API Usability
• Effective communication is also an important part of
getting an API used!
Good
Programming
Practices
User
Interface
Design
API Usability
Effective
Communication
Good programming practices
• To design a good API, you need to use good
development practices
• A good API will follow all of the guidance in Joshua
Bloch’s book, “Effective Java”. A selection:
• Item 13: Minimize the accessibility of classes and members
• Item 38: Check parameters for validity
• Item 56: Adhere to generally accepted naming conventions
• Item 64: Strive for failure atomicity
User interface design
• The most important question in user interface design
is: Who is the user?
• Who are the users of an API? Other developers!
• This should be a group that’s easy for us to understand
• You could get into “personas” if you want: “Mike is a 25-
year old college graduate who learned programming in
high school and reads a lot of xkcd…”
• You also need to know: What are the user’s goals?
• What will the user try to achieve by using your API?
• How will the user measure success?
• How can you help the user succeed?
Four principles for highly usable systems
(D. Norman)
• Good visibility: The possible actions, the states and
the alternatives for action must be exposed
• Good conceptual model: The use of helpful,
consistent and complete abstractions helping the
users to create a proper mental image model of the
system
• Good mapping between actions and results: Natural
mapping between actions and their results
• Good feedback about results of actions: Full and
continuous feedback about the results of actions
Metrics for evaluating usability of a system
(B. Schneiderman)
• Time to learn a system
• Speed of task execution
• Rate of errors
• Knowledge retention over time
• Subjective user satisfaction
Characteristics of a good API (J. Bloch)
• Easy to learn
• Easy to use, even without documentation
• Hard to misuse
• Easy to read and maintain code that uses it
• Sufficiently powerful to satisfy requirements
• Easy to extend
• Appropriate to audience
From Joshua Bloch’s “How to Design a Good API and Why it Matters”
Overview
• Background and Definitions
• The Importance of API Usability
• Guidelines for API Design
• The Importance of Effective Communication in API
Usability
• Questions and Discussion
Realize that publicizing an API
represents a commitment
• An API is a coding “contract”, and users of your API will
expect future versions to be compatible with released
versions
• It’s easy to add new functionality
• It’s hard to delete functionality
• This is why so many methods in the Java API are deprecated
• It’s just wrong to make a method to something
completely different between versions
• I’m glad I can’t come up with a good example for this one!
• This is the most important rule. The rest is all detail.
Begin with the end in mind
• Know what you want your API to achieve
• Mock up several sample applications that will use
your API before you start developing the API itself
• Develop your API using Test-Driven Development
Make conceptually easy things
simple to do
• Use the hidden layers of your API to offload
complexity from the end-user developer
• Example: Letting the user make an audible beep:
Bad API Good API
Open a sound data line
beep(int frequency)
Create a clip object
Generate bytes for the
frequencies
Send the clip to the data line
Close the data line
Make sure all variables are
cleaned up
Construct complete objects only
• Never allow a user to construct an object that is not
fully formed. Bad example:
Foo foo = new Foo();
foo.setCriticalValue(true); // This needs to be
set before the object can be used
• Two problems with this:
• Your API cannot force developers to call methods in a
predictable order
• Additional method calls require the user to learn about
those calls
• Make users think up front about what they need to
provide to create a complete object
Expose the minimum amount of code
• Learn how to use these Java keywords effectively:
Scope: public, private, protected (and package scope)
Modifiers: final, transient
• Using scope and modifiers properly helps users know
what they should and should not touch
• Realize that the more classes and methods you
publish, the more you’ll be accountable for in the
future
Be compact and concise
• Help the user derive the most benefit from the
fewest lines of code
• Example - play music in JFugue:
Player player = new Player();
player.play(“C D E F G A B”);
• Provide the smallest set of functionality in your code
that provides the most benefit
• You could write the “War and Peace” of APIs, and it might
be great, but no one would take the time to learn it all!
Be absolutely correct
• People rely on your API to do exactly what it says it
will do
• Make sure your API works correctly, and generates
correct output
Borrowed from Elliotte Rusty Harold’s
XOM Design Principles
Encode common patterns and
encourage best practices
• Notice when there code that you repeat over and
over in your sample programs
• This common pattern may be something that your users
will do, too
• Make the common code a part of your API
• Notice when you’ve identified the best way to
perform a task or achieve a goal with your API
• This may also be something your users will do
• Make the best practice a part of your API
Report errors immediately and clearly
• Report errors and exceptions as soon as they happen
• Guard against error-prone input by using assertions
at the beginning of a method
• Make errors as verbose as possible
• Bad example: “Can’t find file”
• Good example: “The file filename was not found in folder
folder name”
Overview
• Background and Definitions
• The Importance of API Usability
• Guidelines for API Design
• The Importance of Effective Communication in API
Usability
• Questions and Discussion
The importance of effective
communication in API Usability
• When designing an API, it’s important to use:
• Employ good programming practices
• Perform user interface design
• Now you have a quality API, and you want people to
use it. What next?
• Once the API is complete, your communication about
the API is critical to its success
Engage with the user community
• Allow users to communicate with you, and engage
your users in discussion
• Track requests and defects in a defect tracking
system (e.g., Google Code, Jira)
• Be responsive to email comments from users
• Publish a blog with discussions about your API
• When people contact you, ask them how they’re
using your API!
• You need to know what your users are doing, so you can
make effective changes to future versions of your API
• You may be delighted at some of the responses
Be open in communicating an
evolving API
• If you need to make changes to your published API,
be clear about it
• People with older versions of your API depend on
new versions acting the same way for existing
functionality
Provide clear support materials
• The success of your API project also depends on your
presentation of your material that markets the API:
• Documentation
• Website
• Discussion boards
• If someone goes to your webpage and can't figure
out what your API does, how to download it, how to
use it, and what some simple examples might be,
they probably won't use it
Finally: Delight your users
• Make sure your users enjoy using your API!
• Think of ways to make your API clever and well-
crafted
• Ensure your API anticipates the user’s needs by
providing easy access to features users want
• Prefer enjoyment through effective code as opposed
to humor in class and method names
• That comes off as a little tacky, and humor doesn’t always
translate well
Overview
• Background and Definitions
• The Importance of API Usability
• Guidelines for API Design
• The Importance of Effective Communication in API
Usability
• Questions and Discussion
Resources
• Joshua Bloch, “How to Design a Good API and Why it
Matters”
http://www.youtube.com/watch?v=aAb7hSCtvGw
• Joshua Bloch, “Effective Java”
http://www.amazon.com/Effective-Java-2nd-Joshua-Bloch/dp/0321356683
• Bill Venners, “API Design with Java”
http://www.artima.com/apidesign/
• Five-part discussion with Bill Venners and Elliotte Rusty
Harold on API design for JDOM and XOM
Part 5: http://www.artima.com/intv/xomdesign.html
• Jaroslav Tulach, “Practical API Design” (Apress)
http://www.apress.com/9781430209737
public void saveAsMidi()
{
Player player = new Player();
Pattern pattern = new Pattern("A5q B5q C5q");
try {
player.saveMidi(pattern, new File("MySong.midi"));
} catch (IOException e)
{
// handle IO Exception
}
}
public void loadAndPlayMidi()
{
Player player = new Player();
try {
player.playMidiDirectly(new File("MySong.midi"));
} catch (IOException e)
{
// handle IO Exception
} catch (InvalidMidiDataException e)
{
// handle Invalid MIDI Data Exception
}
}
public void savePattern()
{
Pattern pattern = new Pattern("A5q B5q C5q");
try {
pattern.savePattern(new File("MusicString.jfugue"));
} catch (IOException e)
{
// handle IO Exception
}
}
public void loadPattern()
{
Player player = new Player();
Pattern pattern = null;
try {
pattern = Pattern.loadPattern(new File("MusicString.jfugue"));
player.play(pattern);
Thank You!
David Koelle
davekoelle.com
July 19, 2011
Ad

More Related Content

What's hot (20)

What is an API?
What is an API?What is an API?
What is an API?
Muhammad Zuhdi
 
Introduction To Micro Frontends
Introduction To Micro Frontends Introduction To Micro Frontends
Introduction To Micro Frontends
Meitar Karas
 
REST API
REST APIREST API
REST API
Tofazzal Ahmed
 
API Test Automation
API Test Automation API Test Automation
API Test Automation
SQALab
 
API for Beginners
API for BeginnersAPI for Beginners
API for Beginners
Gustavo De Vita
 
Rest API Security - A quick understanding of Rest API Security
Rest API Security - A quick understanding of Rest API SecurityRest API Security - A quick understanding of Rest API Security
Rest API Security - A quick understanding of Rest API Security
Mohammed Fazuluddin
 
Introduction to ASP.NET
Introduction to ASP.NETIntroduction to ASP.NET
Introduction to ASP.NET
Rajkumarsoy
 
Angular 10 course_content
Angular 10 course_contentAngular 10 course_content
Angular 10 course_content
NAVEENSAGGAM1
 
REST API Design & Development
REST API Design & DevelopmentREST API Design & Development
REST API Design & Development
Ashok Pundit
 
What is REST API? REST API Concepts and Examples | Edureka
What is REST API? REST API Concepts and Examples | EdurekaWhat is REST API? REST API Concepts and Examples | Edureka
What is REST API? REST API Concepts and Examples | Edureka
Edureka!
 
Api presentation
Api presentationApi presentation
Api presentation
Tiago Cardoso
 
Introduction to the Web API
Introduction to the Web APIIntroduction to the Web API
Introduction to the Web API
Brad Genereaux
 
introduction about REST API
introduction about REST APIintroduction about REST API
introduction about REST API
AmilaSilva13
 
Apigee Edge Overview and Roadmap
Apigee Edge Overview and RoadmapApigee Edge Overview and Roadmap
Apigee Edge Overview and Roadmap
Apigee | Google Cloud
 
AngularJS
AngularJSAngularJS
AngularJS
Hiten Pratap Singh
 
Web API testing : A quick glance
Web API testing : A quick glanceWeb API testing : A quick glance
Web API testing : A quick glance
Dhanalaxmi K
 
AngularJS
AngularJSAngularJS
AngularJS
Maurice De Beijer [MVP]
 
API
APIAPI
API
Masters Academy
 
REST-API introduction for developers
REST-API introduction for developersREST-API introduction for developers
REST-API introduction for developers
Patrick Savalle
 
Effective Java - Enum and Annotations
Effective Java - Enum and AnnotationsEffective Java - Enum and Annotations
Effective Java - Enum and Annotations
Roshan Deniyage
 
Introduction To Micro Frontends
Introduction To Micro Frontends Introduction To Micro Frontends
Introduction To Micro Frontends
Meitar Karas
 
API Test Automation
API Test Automation API Test Automation
API Test Automation
SQALab
 
Rest API Security - A quick understanding of Rest API Security
Rest API Security - A quick understanding of Rest API SecurityRest API Security - A quick understanding of Rest API Security
Rest API Security - A quick understanding of Rest API Security
Mohammed Fazuluddin
 
Introduction to ASP.NET
Introduction to ASP.NETIntroduction to ASP.NET
Introduction to ASP.NET
Rajkumarsoy
 
Angular 10 course_content
Angular 10 course_contentAngular 10 course_content
Angular 10 course_content
NAVEENSAGGAM1
 
REST API Design & Development
REST API Design & DevelopmentREST API Design & Development
REST API Design & Development
Ashok Pundit
 
What is REST API? REST API Concepts and Examples | Edureka
What is REST API? REST API Concepts and Examples | EdurekaWhat is REST API? REST API Concepts and Examples | Edureka
What is REST API? REST API Concepts and Examples | Edureka
Edureka!
 
Introduction to the Web API
Introduction to the Web APIIntroduction to the Web API
Introduction to the Web API
Brad Genereaux
 
introduction about REST API
introduction about REST APIintroduction about REST API
introduction about REST API
AmilaSilva13
 
Web API testing : A quick glance
Web API testing : A quick glanceWeb API testing : A quick glance
Web API testing : A quick glance
Dhanalaxmi K
 
REST-API introduction for developers
REST-API introduction for developersREST-API introduction for developers
REST-API introduction for developers
Patrick Savalle
 
Effective Java - Enum and Annotations
Effective Java - Enum and AnnotationsEffective Java - Enum and Annotations
Effective Java - Enum and Annotations
Roshan Deniyage
 

Viewers also liked (12)

Api anti patterns
Api anti patternsApi anti patterns
Api anti patterns
Mike Pearce
 
API Design - 3rd Edition
API Design - 3rd EditionAPI Design - 3rd Edition
API Design - 3rd Edition
Apigee | Google Cloud
 
APIs: the Glue of Cloud Computing
APIs: the Glue of Cloud ComputingAPIs: the Glue of Cloud Computing
APIs: the Glue of Cloud Computing
3scale
 
The hypermedia api
The hypermedia apiThe hypermedia api
The hypermedia api
Inviqa
 
Best Practices for Architecting a Pragmatic Web API.
Best Practices for Architecting a Pragmatic Web API.Best Practices for Architecting a Pragmatic Web API.
Best Practices for Architecting a Pragmatic Web API.
Mario Cardinal
 
Questions product managers should ask customers
Questions product managers should ask customersQuestions product managers should ask customers
Questions product managers should ask customers
ProductPlan
 
Real World API Business Models That Worked
Real World API Business Models That WorkedReal World API Business Models That Worked
Real World API Business Models That Worked
ProgrammableWeb
 
RESTful API Design, Second Edition
RESTful API Design, Second EditionRESTful API Design, Second Edition
RESTful API Design, Second Edition
Apigee | Google Cloud
 
Design Beautiful REST + JSON APIs
Design Beautiful REST + JSON APIsDesign Beautiful REST + JSON APIs
Design Beautiful REST + JSON APIs
Stormpath
 
Welcome to the API Economy: Developing Your API Strategy
Welcome to the API Economy: Developing Your API StrategyWelcome to the API Economy: Developing Your API Strategy
Welcome to the API Economy: Developing Your API Strategy
MuleSoft
 
API Business Models
API Business ModelsAPI Business Models
API Business Models
John Musser
 
HATEOAS 101 - Opinionated Introduction to a REST API Style
HATEOAS 101 - Opinionated Introduction to a REST API StyleHATEOAS 101 - Opinionated Introduction to a REST API Style
HATEOAS 101 - Opinionated Introduction to a REST API Style
Apigee | Google Cloud
 
Api anti patterns
Api anti patternsApi anti patterns
Api anti patterns
Mike Pearce
 
APIs: the Glue of Cloud Computing
APIs: the Glue of Cloud ComputingAPIs: the Glue of Cloud Computing
APIs: the Glue of Cloud Computing
3scale
 
The hypermedia api
The hypermedia apiThe hypermedia api
The hypermedia api
Inviqa
 
Best Practices for Architecting a Pragmatic Web API.
Best Practices for Architecting a Pragmatic Web API.Best Practices for Architecting a Pragmatic Web API.
Best Practices for Architecting a Pragmatic Web API.
Mario Cardinal
 
Questions product managers should ask customers
Questions product managers should ask customersQuestions product managers should ask customers
Questions product managers should ask customers
ProductPlan
 
Real World API Business Models That Worked
Real World API Business Models That WorkedReal World API Business Models That Worked
Real World API Business Models That Worked
ProgrammableWeb
 
Design Beautiful REST + JSON APIs
Design Beautiful REST + JSON APIsDesign Beautiful REST + JSON APIs
Design Beautiful REST + JSON APIs
Stormpath
 
Welcome to the API Economy: Developing Your API Strategy
Welcome to the API Economy: Developing Your API StrategyWelcome to the API Economy: Developing Your API Strategy
Welcome to the API Economy: Developing Your API Strategy
MuleSoft
 
API Business Models
API Business ModelsAPI Business Models
API Business Models
John Musser
 
HATEOAS 101 - Opinionated Introduction to a REST API Style
HATEOAS 101 - Opinionated Introduction to a REST API StyleHATEOAS 101 - Opinionated Introduction to a REST API Style
HATEOAS 101 - Opinionated Introduction to a REST API Style
Apigee | Google Cloud
 
Ad

Similar to Golden Rules of API Design (20)

Practices and Tools for Building Better APIs
Practices and Tools for Building Better APIsPractices and Tools for Building Better APIs
Practices and Tools for Building Better APIs
Peter Hendriks
 
Building a REST API for Longevity
Building a REST API for LongevityBuilding a REST API for Longevity
Building a REST API for Longevity
MuleSoft
 
Practices and tools for building better APIs
Practices and tools for building better APIsPractices and tools for building better APIs
Practices and tools for building better APIs
NLJUG
 
Practices and tools for building better API (JFall 2013)
Practices and tools for building better API (JFall 2013)Practices and tools for building better API (JFall 2013)
Practices and tools for building better API (JFall 2013)
Peter Hendriks
 
How to Design a Good API and Why it Matters.pdf
How to Design a Good API and Why it Matters.pdfHow to Design a Good API and Why it Matters.pdf
How to Design a Good API and Why it Matters.pdf
SimranjyotSuri
 
Full stack conference talk slides
Full stack conference talk slidesFull stack conference talk slides
Full stack conference talk slides
Sameer Al-Sakran
 
SonarQube
SonarQubeSonarQube
SonarQube
Gnanaseelan Jeb
 
Understanding and Executing on API Developer Experience
Understanding and Executing on API Developer ExperienceUnderstanding and Executing on API Developer Experience
Understanding and Executing on API Developer Experience
SmartBear
 
How to design effective APIs
How to design effective APIsHow to design effective APIs
How to design effective APIs
Bansilal Haudakari
 
Designing for efficiency.pdf
Designing for efficiency.pdfDesigning for efficiency.pdf
Designing for efficiency.pdf
Gabriela Véghová
 
API Developer Experience: Why it Matters, and How Documenting Your API with S...
API Developer Experience: Why it Matters, and How Documenting Your API with S...API Developer Experience: Why it Matters, and How Documenting Your API with S...
API Developer Experience: Why it Matters, and How Documenting Your API with S...
SmartBear
 
The API Lifecycle Series: Evolving API Development and Testing from Open Sour...
The API Lifecycle Series: Evolving API Development and Testing from Open Sour...The API Lifecycle Series: Evolving API Development and Testing from Open Sour...
The API Lifecycle Series: Evolving API Development and Testing from Open Sour...
SmartBear
 
Understanding and Executing on API Developer Experience
Understanding and Executing on API Developer ExperienceUnderstanding and Executing on API Developer Experience
Understanding and Executing on API Developer Experience
Keshav Vasudevan
 
User Experience Bootcamp for Developers
User Experience Bootcamp for DevelopersUser Experience Bootcamp for Developers
User Experience Bootcamp for Developers
Catherine Robson
 
5 Keys to API Design - API Days Paris 2013
5 Keys to API Design - API Days Paris 20135 Keys to API Design - API Days Paris 2013
5 Keys to API Design - API Days Paris 2013
Daniel Feist
 
Kevin Whinnery: Best Practices for Cross-Platform Mobile Development
Kevin Whinnery: Best Practices for Cross-Platform Mobile DevelopmentKevin Whinnery: Best Practices for Cross-Platform Mobile Development
Kevin Whinnery: Best Practices for Cross-Platform Mobile Development
Axway Appcelerator
 
Make Your Contribution Count. Adding Value to the API as a Technical Communic...
Make Your Contribution Count. Adding Value to the API as a Technical Communic...Make Your Contribution Count. Adding Value to the API as a Technical Communic...
Make Your Contribution Count. Adding Value to the API as a Technical Communic...
Petko Mikhailov
 
Building the Eventbrite API Ecosystem
Building the Eventbrite API EcosystemBuilding the Eventbrite API Ecosystem
Building the Eventbrite API Ecosystem
Mitch Colleran
 
E Learning Management System By Tuhin Roy Using PHP
E Learning Management System By Tuhin Roy Using PHPE Learning Management System By Tuhin Roy Using PHP
E Learning Management System By Tuhin Roy Using PHP
Tuhin Ray
 
How to design good api
How to design good apiHow to design good api
How to design good api
Osama Shakir
 
Practices and Tools for Building Better APIs
Practices and Tools for Building Better APIsPractices and Tools for Building Better APIs
Practices and Tools for Building Better APIs
Peter Hendriks
 
Building a REST API for Longevity
Building a REST API for LongevityBuilding a REST API for Longevity
Building a REST API for Longevity
MuleSoft
 
Practices and tools for building better APIs
Practices and tools for building better APIsPractices and tools for building better APIs
Practices and tools for building better APIs
NLJUG
 
Practices and tools for building better API (JFall 2013)
Practices and tools for building better API (JFall 2013)Practices and tools for building better API (JFall 2013)
Practices and tools for building better API (JFall 2013)
Peter Hendriks
 
How to Design a Good API and Why it Matters.pdf
How to Design a Good API and Why it Matters.pdfHow to Design a Good API and Why it Matters.pdf
How to Design a Good API and Why it Matters.pdf
SimranjyotSuri
 
Full stack conference talk slides
Full stack conference talk slidesFull stack conference talk slides
Full stack conference talk slides
Sameer Al-Sakran
 
Understanding and Executing on API Developer Experience
Understanding and Executing on API Developer ExperienceUnderstanding and Executing on API Developer Experience
Understanding and Executing on API Developer Experience
SmartBear
 
API Developer Experience: Why it Matters, and How Documenting Your API with S...
API Developer Experience: Why it Matters, and How Documenting Your API with S...API Developer Experience: Why it Matters, and How Documenting Your API with S...
API Developer Experience: Why it Matters, and How Documenting Your API with S...
SmartBear
 
The API Lifecycle Series: Evolving API Development and Testing from Open Sour...
The API Lifecycle Series: Evolving API Development and Testing from Open Sour...The API Lifecycle Series: Evolving API Development and Testing from Open Sour...
The API Lifecycle Series: Evolving API Development and Testing from Open Sour...
SmartBear
 
Understanding and Executing on API Developer Experience
Understanding and Executing on API Developer ExperienceUnderstanding and Executing on API Developer Experience
Understanding and Executing on API Developer Experience
Keshav Vasudevan
 
User Experience Bootcamp for Developers
User Experience Bootcamp for DevelopersUser Experience Bootcamp for Developers
User Experience Bootcamp for Developers
Catherine Robson
 
5 Keys to API Design - API Days Paris 2013
5 Keys to API Design - API Days Paris 20135 Keys to API Design - API Days Paris 2013
5 Keys to API Design - API Days Paris 2013
Daniel Feist
 
Kevin Whinnery: Best Practices for Cross-Platform Mobile Development
Kevin Whinnery: Best Practices for Cross-Platform Mobile DevelopmentKevin Whinnery: Best Practices for Cross-Platform Mobile Development
Kevin Whinnery: Best Practices for Cross-Platform Mobile Development
Axway Appcelerator
 
Make Your Contribution Count. Adding Value to the API as a Technical Communic...
Make Your Contribution Count. Adding Value to the API as a Technical Communic...Make Your Contribution Count. Adding Value to the API as a Technical Communic...
Make Your Contribution Count. Adding Value to the API as a Technical Communic...
Petko Mikhailov
 
Building the Eventbrite API Ecosystem
Building the Eventbrite API EcosystemBuilding the Eventbrite API Ecosystem
Building the Eventbrite API Ecosystem
Mitch Colleran
 
E Learning Management System By Tuhin Roy Using PHP
E Learning Management System By Tuhin Roy Using PHPE Learning Management System By Tuhin Roy Using PHP
E Learning Management System By Tuhin Roy Using PHP
Tuhin Ray
 
How to design good api
How to design good apiHow to design good api
How to design good api
Osama Shakir
 
Ad

Recently uploaded (20)

FL Studio Producer Edition Crack 2025 Full Version
FL Studio Producer Edition Crack 2025 Full VersionFL Studio Producer Edition Crack 2025 Full Version
FL Studio Producer Edition Crack 2025 Full Version
tahirabibi60507
 
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
Andre Hora
 
Automation Techniques in RPA - UiPath Certificate
Automation Techniques in RPA - UiPath CertificateAutomation Techniques in RPA - UiPath Certificate
Automation Techniques in RPA - UiPath Certificate
VICTOR MAESTRE RAMIREZ
 
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Eric D. Schabell
 
Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...
Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...
Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...
Ranjan Baisak
 
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Andre Hora
 
Solidworks Crack 2025 latest new + license code
Solidworks Crack 2025 latest new + license codeSolidworks Crack 2025 latest new + license code
Solidworks Crack 2025 latest new + license code
aneelaramzan63
 
Explaining GitHub Actions Failures with Large Language Models Challenges, In...
Explaining GitHub Actions Failures with Large Language Models Challenges, In...Explaining GitHub Actions Failures with Large Language Models Challenges, In...
Explaining GitHub Actions Failures with Large Language Models Challenges, In...
ssuserb14185
 
Exploring Wayland: A Modern Display Server for the Future
Exploring Wayland: A Modern Display Server for the FutureExploring Wayland: A Modern Display Server for the Future
Exploring Wayland: A Modern Display Server for the Future
ICS
 
What Do Contribution Guidelines Say About Software Testing? (MSR 2025)
What Do Contribution Guidelines Say About Software Testing? (MSR 2025)What Do Contribution Guidelines Say About Software Testing? (MSR 2025)
What Do Contribution Guidelines Say About Software Testing? (MSR 2025)
Andre Hora
 
Requirements in Engineering AI- Enabled Systems: Open Problems and Safe AI Sy...
Requirements in Engineering AI- Enabled Systems: Open Problems and Safe AI Sy...Requirements in Engineering AI- Enabled Systems: Open Problems and Safe AI Sy...
Requirements in Engineering AI- Enabled Systems: Open Problems and Safe AI Sy...
Lionel Briand
 
Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.
Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.
Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.
Dele Amefo
 
Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...
Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...
Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...
AxisTechnolabs
 
Designing AI-Powered APIs on Azure: Best Practices& Considerations
Designing AI-Powered APIs on Azure: Best Practices& ConsiderationsDesigning AI-Powered APIs on Azure: Best Practices& Considerations
Designing AI-Powered APIs on Azure: Best Practices& Considerations
Dinusha Kumarasiri
 
Adobe Master Collection CC Crack Advance Version 2025
Adobe Master Collection CC Crack Advance Version 2025Adobe Master Collection CC Crack Advance Version 2025
Adobe Master Collection CC Crack Advance Version 2025
kashifyounis067
 
Pixologic ZBrush Crack Plus Activation Key [Latest 2025] New Version
Pixologic ZBrush Crack Plus Activation Key [Latest 2025] New VersionPixologic ZBrush Crack Plus Activation Key [Latest 2025] New Version
Pixologic ZBrush Crack Plus Activation Key [Latest 2025] New Version
saimabibi60507
 
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage DashboardsAdobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
BradBedford3
 
How can one start with crypto wallet development.pptx
How can one start with crypto wallet development.pptxHow can one start with crypto wallet development.pptx
How can one start with crypto wallet development.pptx
laravinson24
 
Maxon CINEMA 4D 2025 Crack FREE Download LINK
Maxon CINEMA 4D 2025 Crack FREE Download LINKMaxon CINEMA 4D 2025 Crack FREE Download LINK
Maxon CINEMA 4D 2025 Crack FREE Download LINK
younisnoman75
 
Adobe After Effects Crack FREE FRESH version 2025
Adobe After Effects Crack FREE FRESH version 2025Adobe After Effects Crack FREE FRESH version 2025
Adobe After Effects Crack FREE FRESH version 2025
kashifyounis067
 
FL Studio Producer Edition Crack 2025 Full Version
FL Studio Producer Edition Crack 2025 Full VersionFL Studio Producer Edition Crack 2025 Full Version
FL Studio Producer Edition Crack 2025 Full Version
tahirabibi60507
 
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
Andre Hora
 
Automation Techniques in RPA - UiPath Certificate
Automation Techniques in RPA - UiPath CertificateAutomation Techniques in RPA - UiPath Certificate
Automation Techniques in RPA - UiPath Certificate
VICTOR MAESTRE RAMIREZ
 
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Eric D. Schabell
 
Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...
Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...
Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...
Ranjan Baisak
 
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Andre Hora
 
Solidworks Crack 2025 latest new + license code
Solidworks Crack 2025 latest new + license codeSolidworks Crack 2025 latest new + license code
Solidworks Crack 2025 latest new + license code
aneelaramzan63
 
Explaining GitHub Actions Failures with Large Language Models Challenges, In...
Explaining GitHub Actions Failures with Large Language Models Challenges, In...Explaining GitHub Actions Failures with Large Language Models Challenges, In...
Explaining GitHub Actions Failures with Large Language Models Challenges, In...
ssuserb14185
 
Exploring Wayland: A Modern Display Server for the Future
Exploring Wayland: A Modern Display Server for the FutureExploring Wayland: A Modern Display Server for the Future
Exploring Wayland: A Modern Display Server for the Future
ICS
 
What Do Contribution Guidelines Say About Software Testing? (MSR 2025)
What Do Contribution Guidelines Say About Software Testing? (MSR 2025)What Do Contribution Guidelines Say About Software Testing? (MSR 2025)
What Do Contribution Guidelines Say About Software Testing? (MSR 2025)
Andre Hora
 
Requirements in Engineering AI- Enabled Systems: Open Problems and Safe AI Sy...
Requirements in Engineering AI- Enabled Systems: Open Problems and Safe AI Sy...Requirements in Engineering AI- Enabled Systems: Open Problems and Safe AI Sy...
Requirements in Engineering AI- Enabled Systems: Open Problems and Safe AI Sy...
Lionel Briand
 
Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.
Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.
Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.
Dele Amefo
 
Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...
Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...
Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...
AxisTechnolabs
 
Designing AI-Powered APIs on Azure: Best Practices& Considerations
Designing AI-Powered APIs on Azure: Best Practices& ConsiderationsDesigning AI-Powered APIs on Azure: Best Practices& Considerations
Designing AI-Powered APIs on Azure: Best Practices& Considerations
Dinusha Kumarasiri
 
Adobe Master Collection CC Crack Advance Version 2025
Adobe Master Collection CC Crack Advance Version 2025Adobe Master Collection CC Crack Advance Version 2025
Adobe Master Collection CC Crack Advance Version 2025
kashifyounis067
 
Pixologic ZBrush Crack Plus Activation Key [Latest 2025] New Version
Pixologic ZBrush Crack Plus Activation Key [Latest 2025] New VersionPixologic ZBrush Crack Plus Activation Key [Latest 2025] New Version
Pixologic ZBrush Crack Plus Activation Key [Latest 2025] New Version
saimabibi60507
 
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage DashboardsAdobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
BradBedford3
 
How can one start with crypto wallet development.pptx
How can one start with crypto wallet development.pptxHow can one start with crypto wallet development.pptx
How can one start with crypto wallet development.pptx
laravinson24
 
Maxon CINEMA 4D 2025 Crack FREE Download LINK
Maxon CINEMA 4D 2025 Crack FREE Download LINKMaxon CINEMA 4D 2025 Crack FREE Download LINK
Maxon CINEMA 4D 2025 Crack FREE Download LINK
younisnoman75
 
Adobe After Effects Crack FREE FRESH version 2025
Adobe After Effects Crack FREE FRESH version 2025Adobe After Effects Crack FREE FRESH version 2025
Adobe After Effects Crack FREE FRESH version 2025
kashifyounis067
 

Golden Rules of API Design

  • 1. public void saveAsMidi() { Player player = new Player(); Pattern pattern = new Pattern("A5q B5q C5q"); try { player.saveMidi(pattern, new File("MySong.midi")); } catch (IOException e) { // handle IO Exception } } public void loadAndPlayMidi() { Player player = new Player(); try { player.playMidiDirectly(new File("MySong.midi")); } catch (IOException e) { // handle IO Exception } catch (InvalidMidiDataException e) { // handle Invalid MIDI Data Exception } } public void savePattern() { Pattern pattern = new Pattern("A5q B5q C5q"); try { pattern.savePattern(new File("MusicString.jfugue")); } catch (IOException e) { // handle IO Exception } } public void loadPattern() { Player player = new Player(); Pattern pattern = null; try { pattern = Pattern.loadPattern(new File("MusicString.jfugue")); player.play(pattern); Golden Rules of API Design David Koelle davekoelle.com July 19, 2011
  • 2. Objectives • Learn guidelines for creating a solid API • Understand the importance of API Usability • Consider how even the best-designed API needs to be accompanied with clear documents and guides to succeed
  • 3. Overview • Background and Definitions • The Importance of API Usability • Guidelines for API Design • The Importance of Effective Communication in API Usability • Questions and Discussion
  • 4. Overview • Background and Definitions • The Importance of API Usability • Guidelines for API Design • The Importance of Effective Communication in API Usability • Questions and Discussion
  • 5. Speaker background • David Koelle • First computer: TI-99/4A in 2nd grade • Graduate of Worcester Polytechnic Institute (Massachusetts, USA) • 14-year career spans large and small businesses and start-ups • Three-time Java Rock Star for talks given at JavaOne • David has developed APIs for: • Music Programming (JFugue) • User Interfaces • Graphics and Animation • Business Intelligence • Social Network Analysis
  • 6. Definitions • An Application Programming Interface (API) is comprised of the exposed code that other developers use to access a program’s functionality • Examples: • JFugue API for music programming (Java) • Google Maps API (JavaScript, Flash, and web services) • API Usability is a set of guidelines for creating APIs that others can understand and use effectively
  • 7. Definitions of usability “Usability is how easy, efficient, and pleasant it is to use a service” – Jacob Nielsen “Usability is the effectiveness, efficiency, and satisfaction with which specified users achieve specified goals in particular environments” – ISO-9241 (Ergonomics of Human System Interaction) • These definitions come from the User Interface (UI) community, but are applicable to API Design as well!
  • 8. Components of API Usability • API Usability is informed by good programming practices and user interface design Good Programming Practices User Interface Design API Usability
  • 9. Components of API Usability • Effective communication is also an important part of getting an API used! Good Programming Practices User Interface Design API Usability Effective Communication
  • 10. Good programming practices • To design a good API, you need to use good development practices • A good API will follow all of the guidance in Joshua Bloch’s book, “Effective Java”. A selection: • Item 13: Minimize the accessibility of classes and members • Item 38: Check parameters for validity • Item 56: Adhere to generally accepted naming conventions • Item 64: Strive for failure atomicity
  • 11. User interface design • The most important question in user interface design is: Who is the user? • Who are the users of an API? Other developers! • This should be a group that’s easy for us to understand • You could get into “personas” if you want: “Mike is a 25- year old college graduate who learned programming in high school and reads a lot of xkcd…” • You also need to know: What are the user’s goals? • What will the user try to achieve by using your API? • How will the user measure success? • How can you help the user succeed?
  • 12. Four principles for highly usable systems (D. Norman) • Good visibility: The possible actions, the states and the alternatives for action must be exposed • Good conceptual model: The use of helpful, consistent and complete abstractions helping the users to create a proper mental image model of the system • Good mapping between actions and results: Natural mapping between actions and their results • Good feedback about results of actions: Full and continuous feedback about the results of actions
  • 13. Metrics for evaluating usability of a system (B. Schneiderman) • Time to learn a system • Speed of task execution • Rate of errors • Knowledge retention over time • Subjective user satisfaction
  • 14. Characteristics of a good API (J. Bloch) • Easy to learn • Easy to use, even without documentation • Hard to misuse • Easy to read and maintain code that uses it • Sufficiently powerful to satisfy requirements • Easy to extend • Appropriate to audience From Joshua Bloch’s “How to Design a Good API and Why it Matters”
  • 15. Overview • Background and Definitions • The Importance of API Usability • Guidelines for API Design • The Importance of Effective Communication in API Usability • Questions and Discussion
  • 16. Realize that publicizing an API represents a commitment • An API is a coding “contract”, and users of your API will expect future versions to be compatible with released versions • It’s easy to add new functionality • It’s hard to delete functionality • This is why so many methods in the Java API are deprecated • It’s just wrong to make a method to something completely different between versions • I’m glad I can’t come up with a good example for this one! • This is the most important rule. The rest is all detail.
  • 17. Begin with the end in mind • Know what you want your API to achieve • Mock up several sample applications that will use your API before you start developing the API itself • Develop your API using Test-Driven Development
  • 18. Make conceptually easy things simple to do • Use the hidden layers of your API to offload complexity from the end-user developer • Example: Letting the user make an audible beep: Bad API Good API Open a sound data line beep(int frequency) Create a clip object Generate bytes for the frequencies Send the clip to the data line Close the data line Make sure all variables are cleaned up
  • 19. Construct complete objects only • Never allow a user to construct an object that is not fully formed. Bad example: Foo foo = new Foo(); foo.setCriticalValue(true); // This needs to be set before the object can be used • Two problems with this: • Your API cannot force developers to call methods in a predictable order • Additional method calls require the user to learn about those calls • Make users think up front about what they need to provide to create a complete object
  • 20. Expose the minimum amount of code • Learn how to use these Java keywords effectively: Scope: public, private, protected (and package scope) Modifiers: final, transient • Using scope and modifiers properly helps users know what they should and should not touch • Realize that the more classes and methods you publish, the more you’ll be accountable for in the future
  • 21. Be compact and concise • Help the user derive the most benefit from the fewest lines of code • Example - play music in JFugue: Player player = new Player(); player.play(“C D E F G A B”); • Provide the smallest set of functionality in your code that provides the most benefit • You could write the “War and Peace” of APIs, and it might be great, but no one would take the time to learn it all!
  • 22. Be absolutely correct • People rely on your API to do exactly what it says it will do • Make sure your API works correctly, and generates correct output Borrowed from Elliotte Rusty Harold’s XOM Design Principles
  • 23. Encode common patterns and encourage best practices • Notice when there code that you repeat over and over in your sample programs • This common pattern may be something that your users will do, too • Make the common code a part of your API • Notice when you’ve identified the best way to perform a task or achieve a goal with your API • This may also be something your users will do • Make the best practice a part of your API
  • 24. Report errors immediately and clearly • Report errors and exceptions as soon as they happen • Guard against error-prone input by using assertions at the beginning of a method • Make errors as verbose as possible • Bad example: “Can’t find file” • Good example: “The file filename was not found in folder folder name”
  • 25. Overview • Background and Definitions • The Importance of API Usability • Guidelines for API Design • The Importance of Effective Communication in API Usability • Questions and Discussion
  • 26. The importance of effective communication in API Usability • When designing an API, it’s important to use: • Employ good programming practices • Perform user interface design • Now you have a quality API, and you want people to use it. What next? • Once the API is complete, your communication about the API is critical to its success
  • 27. Engage with the user community • Allow users to communicate with you, and engage your users in discussion • Track requests and defects in a defect tracking system (e.g., Google Code, Jira) • Be responsive to email comments from users • Publish a blog with discussions about your API • When people contact you, ask them how they’re using your API! • You need to know what your users are doing, so you can make effective changes to future versions of your API • You may be delighted at some of the responses
  • 28. Be open in communicating an evolving API • If you need to make changes to your published API, be clear about it • People with older versions of your API depend on new versions acting the same way for existing functionality
  • 29. Provide clear support materials • The success of your API project also depends on your presentation of your material that markets the API: • Documentation • Website • Discussion boards • If someone goes to your webpage and can't figure out what your API does, how to download it, how to use it, and what some simple examples might be, they probably won't use it
  • 30. Finally: Delight your users • Make sure your users enjoy using your API! • Think of ways to make your API clever and well- crafted • Ensure your API anticipates the user’s needs by providing easy access to features users want • Prefer enjoyment through effective code as opposed to humor in class and method names • That comes off as a little tacky, and humor doesn’t always translate well
  • 31. Overview • Background and Definitions • The Importance of API Usability • Guidelines for API Design • The Importance of Effective Communication in API Usability • Questions and Discussion
  • 32. Resources • Joshua Bloch, “How to Design a Good API and Why it Matters” http://www.youtube.com/watch?v=aAb7hSCtvGw • Joshua Bloch, “Effective Java” http://www.amazon.com/Effective-Java-2nd-Joshua-Bloch/dp/0321356683 • Bill Venners, “API Design with Java” http://www.artima.com/apidesign/ • Five-part discussion with Bill Venners and Elliotte Rusty Harold on API design for JDOM and XOM Part 5: http://www.artima.com/intv/xomdesign.html • Jaroslav Tulach, “Practical API Design” (Apress) http://www.apress.com/9781430209737
  • 33. public void saveAsMidi() { Player player = new Player(); Pattern pattern = new Pattern("A5q B5q C5q"); try { player.saveMidi(pattern, new File("MySong.midi")); } catch (IOException e) { // handle IO Exception } } public void loadAndPlayMidi() { Player player = new Player(); try { player.playMidiDirectly(new File("MySong.midi")); } catch (IOException e) { // handle IO Exception } catch (InvalidMidiDataException e) { // handle Invalid MIDI Data Exception } } public void savePattern() { Pattern pattern = new Pattern("A5q B5q C5q"); try { pattern.savePattern(new File("MusicString.jfugue")); } catch (IOException e) { // handle IO Exception } } public void loadPattern() { Player player = new Player(); Pattern pattern = null; try { pattern = Pattern.loadPattern(new File("MusicString.jfugue")); player.play(pattern); Thank You! David Koelle davekoelle.com July 19, 2011