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

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...CA API Management
 
仕様決定、部品化、ディレクションがなぜ重要か
仕様決定、部品化、ディレクションがなぜ重要か仕様決定、部品化、ディレクションがなぜ重要か
仕様決定、部品化、ディレクションがなぜ重要かKohei Otsuka
 
Mobile application development platform
Mobile application development platformMobile application development platform
Mobile application development platformi4consulting.org
 
Mobile Delivery Run Through
Mobile Delivery Run ThroughMobile Delivery Run Through
Mobile Delivery Run ThroughMike Hartington
 
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 languageMarco Cedaro
 
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.pdfTechugo Canada
 
02 API Academy - path to success
02   API Academy - path to success02   API Academy - path to success
02 API Academy - path to successCHARLES Frédéric
 
Sudipta_Mukherjee_Resume-Nov_2022.pdf
Sudipta_Mukherjee_Resume-Nov_2022.pdfSudipta_Mukherjee_Resume-Nov_2022.pdf
Sudipta_Mukherjee_Resume-Nov_2022.pdfSudipta Mukherjee
 
Introduction to Angular for .NET Developers
Introduction to Angular for .NET DevelopersIntroduction to Angular for .NET Developers
Introduction to Angular for .NET DevelopersLaurent Duveau
 
Roadmap to Become Experts.pptx
Roadmap to Become Experts.pptxRoadmap to Become Experts.pptx
Roadmap to Become Experts.pptxdscwidyatamanew
 
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 jsCodecamp Romania
 
Developer experience
Developer experienceDeveloper experience
Developer experienceMailjet
 
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 APILaunchAny
 
Developer Experience (DX) for UX Professionals
Developer Experience (DX) for UX ProfessionalsDeveloper Experience (DX) for UX Professionals
Developer Experience (DX) for UX ProfessionalsIan Jennings
 
Hire expert swift developer
Hire expert swift developerHire expert swift developer
Hire expert swift developerAxis Technolabs
 

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

Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
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
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
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
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 

Recently uploaded (20)

Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
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
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
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
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 

Gem API design