SlideShare a Scribd company logo
1 of 55
Download to read offline
Gem API design
for authors
(and users)

Emily Stolfo
Ruby Engineer at
@EmStolfo

, Adjunct Faculty at Columbia
Many of us
have become
gem authors.
(whether we like it or not)
Our code served a
browser and a
mouse.
Now our code serves
other developers.
Is it just me, or does ____ seem like a
poorly designed piece of software; lots
of magic, poor OOP design, poor
documentation, etc.? I appreciate the
contribution to open source, though.
gem API design is

UX design
The UX Fund
experiment
Great user
experience is
directly reflected
in stock price.
RubyGems
Developer Experience
(DX) team
Drivers
Docs
Tools
gem API design is

UX design
USERS
Know your users.*

* open source users or your colleagues
Listen in.
Read blogs.
Use twitter.
Talk to users.
Give presentations.
Establish trust.
USE
SEMANTIC
VERSIONING
Involve

super users.
UX DESIGN
CONCEPTS
Consistency
Simplicity
Mapping
Consistency

Simplicity

Mapping
Consistency

Simplicity

Mapping
Consistency

Simplicity

Mapping
3 Consistency Considerations
4 Simplicity Suggestions
5 Mapping Mantras
Consistency
Considerations
1. Consider
consistent naming.
2. Consider
consistent style.
3. Consider
consistent behavior.
Simplicity
Suggestions
1. Give classes a
single responsibility.
2. Hide
implementation
details.
attr_reader :name, :connection
...
protected
...
private
...
3. Be frugal with
helpers.
Index creation

X

@posts.text_index(‘title’)

@posts.create_index({ ‘title’ => Mongo::TEXT })
4. Design your API
first.
new driver “fluent API”

X

@orders.find_and_modify(
:query => {},
:new => true,
:update => {:$set =>
{:processed => true})

@orders.find({}).
update_one_then_get({:$set =>
{:processed => true})
Mapping
Mantras
1. Monkey-patching
is mean.
refinements
refine String do
...
end
2. Side effects are
surprising.
Mutating opts

X

def map_reduce(map, reduce, opts={})
...
raw = opts.delete(:raw)
...

def map_reduce(map, reduce, opts={})
opts = opts.dup
raw = opts.delete(:raw)
...
3. Requiring
method chaining
is impolite.
X

@client.pool_manager.primary_pool

@client.primary
4. Informative error
messages are
imperative.
mongoid
5. Documentation
without hesitation.
# inline comments
Documentation tools
README.md
Getting started
http://code.dblock.org/your-first-ruby-gem
Think like a
UX designer.
Get social.
© JEG2
Talk to me about
the Ruby driver :)
Emily Stolfo
emily@mongodb.com
@EmStolfo

More Related Content

Similar to Gem API design

Similar to Gem API design (20)

Developers are People Too! Building a DX-Based API Strategy Ronnie Mitra, Pri...
Developers are People Too! Building a DX-Based API Strategy Ronnie Mitra, Pri...Developers are People Too! Building a DX-Based API Strategy Ronnie Mitra, Pri...
Developers are People Too! Building a DX-Based API Strategy Ronnie Mitra, Pri...
 
仕様決定、部品化、ディレクションがなぜ重要か
仕様決定、部品化、ディレクションがなぜ重要か仕様決定、部品化、ディレクションがなぜ重要か
仕様決定、部品化、ディレクションがなぜ重要か
 
API Design Workflows
API Design WorkflowsAPI Design Workflows
API Design Workflows
 
Mobile application development platform
Mobile application development platformMobile application development platform
Mobile application development platform
 
Mobile Delivery Run Through
Mobile Delivery Run ThroughMobile Delivery Run Through
Mobile Delivery Run Through
 
Paris Web - Javascript as a programming language
Paris Web - Javascript as a programming languageParis Web - Javascript as a programming language
Paris Web - Javascript as a programming language
 
Top iOS App Development Tools You Should Know to Create Outstanding iOS Apps.pdf
Top iOS App Development Tools You Should Know to Create Outstanding iOS Apps.pdfTop iOS App Development Tools You Should Know to Create Outstanding iOS Apps.pdf
Top iOS App Development Tools You Should Know to Create Outstanding iOS Apps.pdf
 
Conversational AI: What's New?
Conversational AI: What's New?Conversational AI: What's New?
Conversational AI: What's New?
 
02 API Academy - path to success
02   API Academy - path to success02   API Academy - path to success
02 API Academy - path to success
 
API-First Design and Django
API-First Design and DjangoAPI-First Design and Django
API-First Design and Django
 
Sudipta_Mukherjee_Resume-Nov_2022.pdf
Sudipta_Mukherjee_Resume-Nov_2022.pdfSudipta_Mukherjee_Resume-Nov_2022.pdf
Sudipta_Mukherjee_Resume-Nov_2022.pdf
 
Introduction to Angular for .NET Developers
Introduction to Angular for .NET DevelopersIntroduction to Angular for .NET Developers
Introduction to Angular for .NET Developers
 
Angular JS - UI Development Online Training
Angular JS - UI Development Online TrainingAngular JS - UI Development Online Training
Angular JS - UI Development Online Training
 
Roadmap to Become Experts.pptx
Roadmap to Become Experts.pptxRoadmap to Become Experts.pptx
Roadmap to Become Experts.pptx
 
Flavius olaru logicless ui prototyping with node js
Flavius olaru   logicless ui prototyping with node jsFlavius olaru   logicless ui prototyping with node js
Flavius olaru logicless ui prototyping with node js
 
Developer experience
Developer experienceDeveloper experience
Developer experience
 
How to Design and Build a Great Web API
How to Design and Build a Great Web APIHow to Design and Build a Great Web API
How to Design and Build a Great Web API
 
Developer Experience (DX) for UX Professionals
Developer Experience (DX) for UX ProfessionalsDeveloper Experience (DX) for UX Professionals
Developer Experience (DX) for UX Professionals
 
Hire expert swift developer
Hire expert swift developerHire expert swift developer
Hire expert swift developer
 
Top 10 Expertise of UI_UX Developers
Top 10 Expertise of UI_UX DevelopersTop 10 Expertise of UI_UX Developers
Top 10 Expertise of UI_UX Developers
 

Recently uploaded

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Recently uploaded (20)

Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 

Gem API design