SlideShare une entreprise Scribd logo
1  sur  36
Télécharger pour lire hors ligne
LET’S BUILD BETTER NODE
MODULES
NODE SUMMIT
DECEMBER 2013

Copyright © twilio Inc. 2013
HI. I’M KEVIN.
developer evangelist @ twilio
What is twilio?
twilio makes it easy for developers to
integrate voice calling and messaging
into web and native mobile applications
“The goal is to have lots of user-created
modules, that are all single-purpose and
focused...so you can iterate get the best
experience possible...”
https://scalenpm.org
49,000
PACKAGES
PyPI: ~37K | RubyGems: ~67K | NuGet: ~18K
6,000,000+
DOWNLOADS PER DAY
Downloads in millions for October

request

optimist

connect

lodash

0

0.35

0.7

1.05

1.4

USERLAND CARRIES A HEAVY LOAD
IF USERLAND SUCKS,
NODE SUCKS.
HOW WE CAN HELP
• Provide accurate documentation optimized for how people read on
the internet (scanning and searching)
• Design idiomatic APIs that optimize for the job your module will be
hired to do
• Implement test automation and basic release management
DOCUMENTATION
DOCUMENT ALL THE THINGS
• Very few userland modules have effective docs - common open
source problem
• Every module has different documentation needs
• Great resource: Kevin Burke’s talk on this subject
• Two most important components for node modules:
• README (quick start)
• API Docs
AN EFFECTIVE README
• Focus on the job your module will be “hired” to do
• Get user to success ASAP by staying focused:
• What job does your module do?
• How do you install/configure it?
• ~3 examples of how to do the thing your module would be
hired to do
• Link to API docs and deeper info sources
CASE STUDIES
• Mongoose: https://npmjs.org/package/mongoose
• jsdom: https://npmjs.org/package/jsdom
• browserify: https://npmjs.org/package/browserify
• request: https://npmjs.org/package/request
• node-uuid: https://npmjs.org/package/node-uuid
EFFECTIVE API DOCS
• Describe the complete surface area of the API
• Provide context for how the API is meant to be used
• Make content readable and scannable
• Provide complete and correct examples, but do not rely on them as
API documentation
• “Read the tests” is a cop out (see above)
DESCRIBING A NODE.JS API
• Document all properties and functions from module.exports (harder
than it sounds)
• Document all function signatures
• Function docs should ideally have:
• Return value/type
• Argument types
• Example usage
PROVIDING CONTEXT
• Show how your code is intended to be used
• Demonstrate how it interconnects with other modules/platform
features
• Describe high-level use cases and concepts unique to your module
MAKE CONTENT READABLE
• Users don’t read docs word for word - they scan in an F shape,
looking for relevant bits
• Include a table of contents for longer content (https://github.com/
thlorenz/doctoc)
• Make the first 3-5 words of every line contain the most information
possible
• Use headers/images/code to break up scary blocks of text
• Limit text on a page to columns of ~80 characters
PROVIDE EXAMPLES
• Reinforce written docs with sample code that shows actual usage
• Ideally, examples should be copy/cut/paste ready - include any
necessary setup/teardown, including the “require”
• Accuracy is key - broken examples are super frustrating
CASE STUDIES
• Mongoose: http://mongoosejs.com/index.html
• express: http://expressjs.com/api.html
• browserify: https://github.com/substack/node-browserify
• request: https://github.com/mikeal/request
• node-uuid: https://npmjs.org/package/node-uuid
API DESIGN
NODE.JS MODULE API DESIGN
• Check out: https://www.youtube.com/watch?v=aAb7hSCtvGw
• Design for async usage
• Use streams for I/O
• Be mindful of the job your module has been hired to do
DESIGNING FOR ASYNC
• Do not release Zalgo
• Node core modules use a specific type of signature for async APIs
that require callbacks
• Function takes whatever arguments, and a callback
• Callback is called with any error received as the first argument,
formatted data is the second.
• Sometimes there’s a third arg with a “raw” value in userland
DESIGN FOR STREAMS
• If you do any sort of I/O, you’d do well to make your interface speak
streams
• Your API will interoperate well with the rest of the node ecosystem if
you work with readable and writable streams
• “When you grok streams, you grok node” - Isaac paraphrase
BE MINDFUL OF YOUR PURPOSE
• Your module might do a few different things, but it probably has a
few 80% use cases
• Your API should be designed to do those jobs as quickly and
efficiently as possible, with sensible default behavior
CASE STUDIES
• browserify: https://github.com/substack/node-browserify
• request: https://github.com/mikeal/request
• twilio: http://twilio.github.io/twilio-node
TESTING AND RELEASES
MANAGING YOUR PROJECT
• Ensure quality with testing and test automation (which can be super
easy)
• Ensure sanity with your module releases by using semantic
versioning
MANAGING YOUR PROJECT
• Promote quality with testing and test automation (which can be
super easy)
• Ensure sanity with your module releases by using semantic
versioning
TESTING/AUTOMATION
• Lots of great test frameworks, pick your favorite or just use assert
• Do support “npm test”
• Travis CI is your friend, and super easy to set up
RELEASE MANAGEMENT
• If you follow semantic versioning, you’re probably doing fine
• If an API breaks from 1.4 to 1.5, that’s a Very Bad Thing
• Use git tags that match your npm versions
• Doing the above makes release notes/change log very easy
CASE STUDIES

• twilio: http://twilio.github.io/twilio-node
WRAPPING UP
• You probably don’t get paid to write and share your module - thank
you for contributing!
• node.js relies on userland modules more than any other major
server-side platform
• If we care about the node ecosystem and community, we all have to
step up with the quality of our contributions
THANK YOU!
@kevinwhinnery
kw@twilio.com
http://github.com/kwhinnery
http://slideshare.net/kwhinnery

Contenu connexe

Tendances

NativeScript Developer Day Keynote - Todd Anglin & Burke Holland
NativeScript Developer Day Keynote - Todd Anglin & Burke HollandNativeScript Developer Day Keynote - Todd Anglin & Burke Holland
NativeScript Developer Day Keynote - Todd Anglin & Burke HollandBrian Rinaldi
 
Introduction to Django-Celery and Supervisor
Introduction to Django-Celery and SupervisorIntroduction to Django-Celery and Supervisor
Introduction to Django-Celery and SupervisorSuresh Kumar
 
AngularJS Anatomy & Directives
AngularJS Anatomy & DirectivesAngularJS Anatomy & Directives
AngularJS Anatomy & DirectivesDigikrit
 
Managing SharePoint Anywhere with Windows PowerShell
Managing SharePoint Anywhere with Windows PowerShellManaging SharePoint Anywhere with Windows PowerShell
Managing SharePoint Anywhere with Windows PowerShellRyan Dennis
 
2014 SpiceWorld London Breakout
2014 SpiceWorld London Breakout2014 SpiceWorld London Breakout
2014 SpiceWorld London BreakoutThomas Lee
 
.NET Day Switzerland 2019 - DOCKER + AZURE DEVOPS + KUBERNETES = ♥
.NET Day Switzerland 2019 - DOCKER + AZURE DEVOPS + KUBERNETES = ♥.NET Day Switzerland 2019 - DOCKER + AZURE DEVOPS + KUBERNETES = ♥
.NET Day Switzerland 2019 - DOCKER + AZURE DEVOPS + KUBERNETES = ♥Marc Müller
 
Untangling - fall2017 - week 9
Untangling - fall2017 - week 9Untangling - fall2017 - week 9
Untangling - fall2017 - week 9Derek Jacoby
 
Build PWA with Ionic Toolkit
Build PWA with Ionic ToolkitBuild PWA with Ionic Toolkit
Build PWA with Ionic ToolkitPavel Kurnosov
 
Parallel Testing with Python with Selenium and Sauce Labs
Parallel Testing with Python with Selenium and Sauce LabsParallel Testing with Python with Selenium and Sauce Labs
Parallel Testing with Python with Selenium and Sauce LabsSauce Labs
 
Serverless meetup - OpenWhisk overview and architecture
Serverless meetup - OpenWhisk overview and architectureServerless meetup - OpenWhisk overview and architecture
Serverless meetup - OpenWhisk overview and architectureSandeep Paliwal
 
Crafting interactive troubleshooting guides and team documentation for your K...
Crafting interactive troubleshooting guides and team documentation for your K...Crafting interactive troubleshooting guides and team documentation for your K...
Crafting interactive troubleshooting guides and team documentation for your K...Manning Publications
 
Amazon Web Services for the .NET Developer
Amazon Web Services for the .NET DeveloperAmazon Web Services for the .NET Developer
Amazon Web Services for the .NET DeveloperRob Gillen
 
DCSF 19 Modernizing Insurance with Docker Enterprise: The Physicians Mutual ...
DCSF 19 Modernizing Insurance with Docker Enterprise:  The Physicians Mutual ...DCSF 19 Modernizing Insurance with Docker Enterprise:  The Physicians Mutual ...
DCSF 19 Modernizing Insurance with Docker Enterprise: The Physicians Mutual ...Docker, Inc.
 
Untangling - fall2017 - week 10
Untangling - fall2017 - week 10Untangling - fall2017 - week 10
Untangling - fall2017 - week 10Derek Jacoby
 
Serverless Summit India 2017: Fission
Serverless Summit India 2017: FissionServerless Summit India 2017: Fission
Serverless Summit India 2017: FissionVishal Biyani
 
Rik Hepworth - ARM Yourself for Effective Azure Provisioning
Rik Hepworth - ARM Yourself for Effective Azure ProvisioningRik Hepworth - ARM Yourself for Effective Azure Provisioning
Rik Hepworth - ARM Yourself for Effective Azure ProvisioningWinOps Conf
 
ASP.NET Core deployment options
ASP.NET Core deployment optionsASP.NET Core deployment options
ASP.NET Core deployment optionsKen Cenerelli
 

Tendances (20)

NativeScript Developer Day Keynote - Todd Anglin & Burke Holland
NativeScript Developer Day Keynote - Todd Anglin & Burke HollandNativeScript Developer Day Keynote - Todd Anglin & Burke Holland
NativeScript Developer Day Keynote - Todd Anglin & Burke Holland
 
Introduction to Django-Celery and Supervisor
Introduction to Django-Celery and SupervisorIntroduction to Django-Celery and Supervisor
Introduction to Django-Celery and Supervisor
 
AngularJS Anatomy & Directives
AngularJS Anatomy & DirectivesAngularJS Anatomy & Directives
AngularJS Anatomy & Directives
 
Managing Jenkins with Python
Managing Jenkins with PythonManaging Jenkins with Python
Managing Jenkins with Python
 
Managing SharePoint Anywhere with Windows PowerShell
Managing SharePoint Anywhere with Windows PowerShellManaging SharePoint Anywhere with Windows PowerShell
Managing SharePoint Anywhere with Windows PowerShell
 
2014 SpiceWorld London Breakout
2014 SpiceWorld London Breakout2014 SpiceWorld London Breakout
2014 SpiceWorld London Breakout
 
.NET Day Switzerland 2019 - DOCKER + AZURE DEVOPS + KUBERNETES = ♥
.NET Day Switzerland 2019 - DOCKER + AZURE DEVOPS + KUBERNETES = ♥.NET Day Switzerland 2019 - DOCKER + AZURE DEVOPS + KUBERNETES = ♥
.NET Day Switzerland 2019 - DOCKER + AZURE DEVOPS + KUBERNETES = ♥
 
Untangling - fall2017 - week 9
Untangling - fall2017 - week 9Untangling - fall2017 - week 9
Untangling - fall2017 - week 9
 
Build PWA with Ionic Toolkit
Build PWA with Ionic ToolkitBuild PWA with Ionic Toolkit
Build PWA with Ionic Toolkit
 
Parallel Testing with Python with Selenium and Sauce Labs
Parallel Testing with Python with Selenium and Sauce LabsParallel Testing with Python with Selenium and Sauce Labs
Parallel Testing with Python with Selenium and Sauce Labs
 
Serverless meetup - OpenWhisk overview and architecture
Serverless meetup - OpenWhisk overview and architectureServerless meetup - OpenWhisk overview and architecture
Serverless meetup - OpenWhisk overview and architecture
 
Crafting interactive troubleshooting guides and team documentation for your K...
Crafting interactive troubleshooting guides and team documentation for your K...Crafting interactive troubleshooting guides and team documentation for your K...
Crafting interactive troubleshooting guides and team documentation for your K...
 
Amazon Web Services for the .NET Developer
Amazon Web Services for the .NET DeveloperAmazon Web Services for the .NET Developer
Amazon Web Services for the .NET Developer
 
DCSF 19 Modernizing Insurance with Docker Enterprise: The Physicians Mutual ...
DCSF 19 Modernizing Insurance with Docker Enterprise:  The Physicians Mutual ...DCSF 19 Modernizing Insurance with Docker Enterprise:  The Physicians Mutual ...
DCSF 19 Modernizing Insurance with Docker Enterprise: The Physicians Mutual ...
 
Azure CLI 2.0 Tips and Tricks
Azure CLI 2.0 Tips and TricksAzure CLI 2.0 Tips and Tricks
Azure CLI 2.0 Tips and Tricks
 
Untangling - fall2017 - week 10
Untangling - fall2017 - week 10Untangling - fall2017 - week 10
Untangling - fall2017 - week 10
 
Serverless Summit India 2017: Fission
Serverless Summit India 2017: FissionServerless Summit India 2017: Fission
Serverless Summit India 2017: Fission
 
Introduction to PowerShell at Chicago Code Camp 2014
Introduction to PowerShell at Chicago Code Camp 2014Introduction to PowerShell at Chicago Code Camp 2014
Introduction to PowerShell at Chicago Code Camp 2014
 
Rik Hepworth - ARM Yourself for Effective Azure Provisioning
Rik Hepworth - ARM Yourself for Effective Azure ProvisioningRik Hepworth - ARM Yourself for Effective Azure Provisioning
Rik Hepworth - ARM Yourself for Effective Azure Provisioning
 
ASP.NET Core deployment options
ASP.NET Core deployment optionsASP.NET Core deployment options
ASP.NET Core deployment options
 

En vedette

En vedette (8)

Mobile demo-days
Mobile demo-daysMobile demo-days
Mobile demo-days
 
Marketing de Luxo Digital
Marketing de Luxo Digital Marketing de Luxo Digital
Marketing de Luxo Digital
 
The Right Metrics to Optimize: Three metrics every marketer should focus on
The Right Metrics to Optimize: Three metrics every marketer should focus onThe Right Metrics to Optimize: Three metrics every marketer should focus on
The Right Metrics to Optimize: Three metrics every marketer should focus on
 
Taking UX to the Real World
Taking UX to the Real WorldTaking UX to the Real World
Taking UX to the Real World
 
Pharma Digital IQ
Pharma Digital IQPharma Digital IQ
Pharma Digital IQ
 
Digital Strategy Report Card: Is your EDU passing or failing?
Digital Strategy Report Card: Is your EDU passing or failing?Digital Strategy Report Card: Is your EDU passing or failing?
Digital Strategy Report Card: Is your EDU passing or failing?
 
JavaScript as a First-Class Citizen on iOS 7
JavaScript as a First-Class Citizen on iOS 7JavaScript as a First-Class Citizen on iOS 7
JavaScript as a First-Class Citizen on iOS 7
 
Whats New in Titanium 0.7
Whats New in Titanium 0.7Whats New in Titanium 0.7
Whats New in Titanium 0.7
 

Similaire à Let's Write Better Node Modules

Starting from scratch in 2017
Starting from scratch in 2017Starting from scratch in 2017
Starting from scratch in 2017Stefano Bonetta
 
API workshop: Introduction to APIs (TC Camp)
API workshop: Introduction to APIs (TC Camp)API workshop: Introduction to APIs (TC Camp)
API workshop: Introduction to APIs (TC Camp)Tom Johnson
 
Why real integration developers ride Camels
Why real integration developers ride CamelsWhy real integration developers ride Camels
Why real integration developers ride CamelsChristian Posta
 
Autoframework design
Autoframework designAutoframework design
Autoframework designForge Events
 
Creating and Maintaining an Open Source Library
Creating and Maintaining an Open Source LibraryCreating and Maintaining an Open Source Library
Creating and Maintaining an Open Source LibraryNicholas Schweitzer
 
API Description Languages
API Description LanguagesAPI Description Languages
API Description LanguagesAkana
 
API Description Languages
API Description LanguagesAPI Description Languages
API Description LanguagesAkana
 
Publishing strategies for API documentation
Publishing strategies for API documentationPublishing strategies for API documentation
Publishing strategies for API documentationTom Johnson
 
First Look at Azure Logic Apps (BAUG)
First Look at Azure Logic Apps (BAUG)First Look at Azure Logic Apps (BAUG)
First Look at Azure Logic Apps (BAUG)Daniel Toomey
 
API Description Languages: Which Is The Right One For Me?
 API Description Languages: Which Is The Right One For Me?  API Description Languages: Which Is The Right One For Me?
API Description Languages: Which Is The Right One For Me? ProgrammableWeb
 
Continuous Deployment @ AWS Re:Invent
Continuous Deployment @ AWS Re:InventContinuous Deployment @ AWS Re:Invent
Continuous Deployment @ AWS Re:InventJohn Schneider
 
Continuous Integration and Deployment Best Practices on AWS (ARC307) | AWS re...
Continuous Integration and Deployment Best Practices on AWS (ARC307) | AWS re...Continuous Integration and Deployment Best Practices on AWS (ARC307) | AWS re...
Continuous Integration and Deployment Best Practices on AWS (ARC307) | AWS re...Amazon Web Services
 

Similaire à Let's Write Better Node Modules (20)

Javascript best practices
Javascript best practicesJavascript best practices
Javascript best practices
 
Stackato v5
Stackato v5Stackato v5
Stackato v5
 
Stackato v6
Stackato v6Stackato v6
Stackato v6
 
Stackato v4
Stackato v4Stackato v4
Stackato v4
 
Stackato
StackatoStackato
Stackato
 
Starting from scratch in 2017
Starting from scratch in 2017Starting from scratch in 2017
Starting from scratch in 2017
 
Stackato v2
Stackato v2Stackato v2
Stackato v2
 
API workshop: Introduction to APIs (TC Camp)
API workshop: Introduction to APIs (TC Camp)API workshop: Introduction to APIs (TC Camp)
API workshop: Introduction to APIs (TC Camp)
 
Stackato v3
Stackato v3Stackato v3
Stackato v3
 
Why real integration developers ride Camels
Why real integration developers ride CamelsWhy real integration developers ride Camels
Why real integration developers ride Camels
 
Autoframework design
Autoframework designAutoframework design
Autoframework design
 
Creating and Maintaining an Open Source Library
Creating and Maintaining an Open Source LibraryCreating and Maintaining an Open Source Library
Creating and Maintaining an Open Source Library
 
API Description Languages
API Description LanguagesAPI Description Languages
API Description Languages
 
API Description Languages
API Description LanguagesAPI Description Languages
API Description Languages
 
Publishing strategies for API documentation
Publishing strategies for API documentationPublishing strategies for API documentation
Publishing strategies for API documentation
 
Apache Drill (ver. 0.2)
Apache Drill (ver. 0.2)Apache Drill (ver. 0.2)
Apache Drill (ver. 0.2)
 
First Look at Azure Logic Apps (BAUG)
First Look at Azure Logic Apps (BAUG)First Look at Azure Logic Apps (BAUG)
First Look at Azure Logic Apps (BAUG)
 
API Description Languages: Which Is The Right One For Me?
 API Description Languages: Which Is The Right One For Me?  API Description Languages: Which Is The Right One For Me?
API Description Languages: Which Is The Right One For Me?
 
Continuous Deployment @ AWS Re:Invent
Continuous Deployment @ AWS Re:InventContinuous Deployment @ AWS Re:Invent
Continuous Deployment @ AWS Re:Invent
 
Continuous Integration and Deployment Best Practices on AWS (ARC307) | AWS re...
Continuous Integration and Deployment Best Practices on AWS (ARC307) | AWS re...Continuous Integration and Deployment Best Practices on AWS (ARC307) | AWS re...
Continuous Integration and Deployment Best Practices on AWS (ARC307) | AWS re...
 

Plus de Kevin Whinnery

Get Pumped for the HTML 5 Gamepad API
Get Pumped for the HTML 5 Gamepad APIGet Pumped for the HTML 5 Gamepad API
Get Pumped for the HTML 5 Gamepad APIKevin Whinnery
 
Designing Modules for the Browser and Node with Browserify
Designing Modules for the Browser and Node with BrowserifyDesigning Modules for the Browser and Node with Browserify
Designing Modules for the Browser and Node with BrowserifyKevin Whinnery
 
Second Screen Apps with the Google Cast SDK
Second Screen Apps with the Google Cast SDKSecond Screen Apps with the Google Cast SDK
Second Screen Apps with the Google Cast SDKKevin Whinnery
 
Best Practices for Cross-Platform Native Applications
Best Practices for Cross-Platform Native ApplicationsBest Practices for Cross-Platform Native Applications
Best Practices for Cross-Platform Native ApplicationsKevin Whinnery
 
Write Better JavaScript
Write Better JavaScriptWrite Better JavaScript
Write Better JavaScriptKevin Whinnery
 
Write Better JavaScript
Write Better JavaScriptWrite Better JavaScript
Write Better JavaScriptKevin Whinnery
 
Lessons Learned From Applications That Kicked Titanium's Ass
Lessons Learned From Applications That Kicked Titanium's AssLessons Learned From Applications That Kicked Titanium's Ass
Lessons Learned From Applications That Kicked Titanium's AssKevin Whinnery
 
Titanium Overview (Mobile March 2011)
Titanium Overview (Mobile March 2011)Titanium Overview (Mobile March 2011)
Titanium Overview (Mobile March 2011)Kevin Whinnery
 
What's New in Titanium 1.5
What's New in Titanium 1.5What's New in Titanium 1.5
What's New in Titanium 1.5Kevin Whinnery
 
OSCON Titanium Tutorial
OSCON Titanium TutorialOSCON Titanium Tutorial
OSCON Titanium TutorialKevin Whinnery
 
Getting Started with Titanium
Getting Started with TitaniumGetting Started with Titanium
Getting Started with TitaniumKevin Whinnery
 

Plus de Kevin Whinnery (12)

Get Pumped for the HTML 5 Gamepad API
Get Pumped for the HTML 5 Gamepad APIGet Pumped for the HTML 5 Gamepad API
Get Pumped for the HTML 5 Gamepad API
 
Designing Modules for the Browser and Node with Browserify
Designing Modules for the Browser and Node with BrowserifyDesigning Modules for the Browser and Node with Browserify
Designing Modules for the Browser and Node with Browserify
 
Second Screen Apps with the Google Cast SDK
Second Screen Apps with the Google Cast SDKSecond Screen Apps with the Google Cast SDK
Second Screen Apps with the Google Cast SDK
 
Best Practices for Cross-Platform Native Applications
Best Practices for Cross-Platform Native ApplicationsBest Practices for Cross-Platform Native Applications
Best Practices for Cross-Platform Native Applications
 
Write Better JavaScript
Write Better JavaScriptWrite Better JavaScript
Write Better JavaScript
 
Write Better JavaScript
Write Better JavaScriptWrite Better JavaScript
Write Better JavaScript
 
Lessons Learned From Applications That Kicked Titanium's Ass
Lessons Learned From Applications That Kicked Titanium's AssLessons Learned From Applications That Kicked Titanium's Ass
Lessons Learned From Applications That Kicked Titanium's Ass
 
Titanium Overview (Mobile March 2011)
Titanium Overview (Mobile March 2011)Titanium Overview (Mobile March 2011)
Titanium Overview (Mobile March 2011)
 
What's New in Titanium 1.5
What's New in Titanium 1.5What's New in Titanium 1.5
What's New in Titanium 1.5
 
OSCON Titanium Tutorial
OSCON Titanium TutorialOSCON Titanium Tutorial
OSCON Titanium Tutorial
 
Titanium @ Minnebar
Titanium @ MinnebarTitanium @ Minnebar
Titanium @ Minnebar
 
Getting Started with Titanium
Getting Started with TitaniumGetting Started with Titanium
Getting Started with Titanium
 

Dernier

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
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 TerraformAndrey Devyatkin
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
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, Adobeapidays
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Zilliz
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxRemote DBA Services
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
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 Ontologyjohnbeverley2021
 
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 FMESafe Software
 
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 AmsterdamUiPathCommunity
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
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, ...Angeliki Cooney
 
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 2024Victor Rentea
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
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...apidays
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 

Dernier (20)

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
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
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
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
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
[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
 
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
 
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
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
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, ...
 
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
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
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...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 

Let's Write Better Node Modules

  • 1. LET’S BUILD BETTER NODE MODULES NODE SUMMIT DECEMBER 2013 Copyright © twilio Inc. 2013
  • 2. HI. I’M KEVIN. developer evangelist @ twilio
  • 3. What is twilio? twilio makes it easy for developers to integrate voice calling and messaging into web and native mobile applications
  • 4.
  • 5. “The goal is to have lots of user-created modules, that are all single-purpose and focused...so you can iterate get the best experience possible...”
  • 6.
  • 8. 49,000 PACKAGES PyPI: ~37K | RubyGems: ~67K | NuGet: ~18K
  • 10. Downloads in millions for October request optimist connect lodash 0 0.35 0.7 1.05 1.4 USERLAND CARRIES A HEAVY LOAD
  • 12. HOW WE CAN HELP • Provide accurate documentation optimized for how people read on the internet (scanning and searching) • Design idiomatic APIs that optimize for the job your module will be hired to do • Implement test automation and basic release management
  • 14. DOCUMENT ALL THE THINGS • Very few userland modules have effective docs - common open source problem • Every module has different documentation needs • Great resource: Kevin Burke’s talk on this subject • Two most important components for node modules: • README (quick start) • API Docs
  • 15. AN EFFECTIVE README • Focus on the job your module will be “hired” to do • Get user to success ASAP by staying focused: • What job does your module do? • How do you install/configure it? • ~3 examples of how to do the thing your module would be hired to do • Link to API docs and deeper info sources
  • 16. CASE STUDIES • Mongoose: https://npmjs.org/package/mongoose • jsdom: https://npmjs.org/package/jsdom • browserify: https://npmjs.org/package/browserify • request: https://npmjs.org/package/request • node-uuid: https://npmjs.org/package/node-uuid
  • 17. EFFECTIVE API DOCS • Describe the complete surface area of the API • Provide context for how the API is meant to be used • Make content readable and scannable • Provide complete and correct examples, but do not rely on them as API documentation • “Read the tests” is a cop out (see above)
  • 18. DESCRIBING A NODE.JS API • Document all properties and functions from module.exports (harder than it sounds) • Document all function signatures • Function docs should ideally have: • Return value/type • Argument types • Example usage
  • 19. PROVIDING CONTEXT • Show how your code is intended to be used • Demonstrate how it interconnects with other modules/platform features • Describe high-level use cases and concepts unique to your module
  • 20. MAKE CONTENT READABLE • Users don’t read docs word for word - they scan in an F shape, looking for relevant bits • Include a table of contents for longer content (https://github.com/ thlorenz/doctoc) • Make the first 3-5 words of every line contain the most information possible • Use headers/images/code to break up scary blocks of text • Limit text on a page to columns of ~80 characters
  • 21. PROVIDE EXAMPLES • Reinforce written docs with sample code that shows actual usage • Ideally, examples should be copy/cut/paste ready - include any necessary setup/teardown, including the “require” • Accuracy is key - broken examples are super frustrating
  • 22. CASE STUDIES • Mongoose: http://mongoosejs.com/index.html • express: http://expressjs.com/api.html • browserify: https://github.com/substack/node-browserify • request: https://github.com/mikeal/request • node-uuid: https://npmjs.org/package/node-uuid
  • 24. NODE.JS MODULE API DESIGN • Check out: https://www.youtube.com/watch?v=aAb7hSCtvGw • Design for async usage • Use streams for I/O • Be mindful of the job your module has been hired to do
  • 25. DESIGNING FOR ASYNC • Do not release Zalgo • Node core modules use a specific type of signature for async APIs that require callbacks • Function takes whatever arguments, and a callback • Callback is called with any error received as the first argument, formatted data is the second. • Sometimes there’s a third arg with a “raw” value in userland
  • 26. DESIGN FOR STREAMS • If you do any sort of I/O, you’d do well to make your interface speak streams • Your API will interoperate well with the rest of the node ecosystem if you work with readable and writable streams • “When you grok streams, you grok node” - Isaac paraphrase
  • 27. BE MINDFUL OF YOUR PURPOSE • Your module might do a few different things, but it probably has a few 80% use cases • Your API should be designed to do those jobs as quickly and efficiently as possible, with sensible default behavior
  • 28. CASE STUDIES • browserify: https://github.com/substack/node-browserify • request: https://github.com/mikeal/request • twilio: http://twilio.github.io/twilio-node
  • 30. MANAGING YOUR PROJECT • Ensure quality with testing and test automation (which can be super easy) • Ensure sanity with your module releases by using semantic versioning
  • 31. MANAGING YOUR PROJECT • Promote quality with testing and test automation (which can be super easy) • Ensure sanity with your module releases by using semantic versioning
  • 32. TESTING/AUTOMATION • Lots of great test frameworks, pick your favorite or just use assert • Do support “npm test” • Travis CI is your friend, and super easy to set up
  • 33. RELEASE MANAGEMENT • If you follow semantic versioning, you’re probably doing fine • If an API breaks from 1.4 to 1.5, that’s a Very Bad Thing • Use git tags that match your npm versions • Doing the above makes release notes/change log very easy
  • 34. CASE STUDIES • twilio: http://twilio.github.io/twilio-node
  • 35. WRAPPING UP • You probably don’t get paid to write and share your module - thank you for contributing! • node.js relies on userland modules more than any other major server-side platform • If we care about the node ecosystem and community, we all have to step up with the quality of our contributions