JS LIBRARIES
How to & How not to
Maël Nison, @arcanis
DEPENDENCY MANAGEMENT
- Require.js (Almond ?)
- Browserify
- CommonJS-everywhere
- Cat *.js > output.js
- No dependencies !
CONCEPTION
- Could worth a talk by itself
- Where does the user expects to find components ?
- Always consider the Demeter Law
LIBRARY API
- "Is it pretty" is a bad question
- "Is it flexible enough" is a good one
- Will your users understand ?
- Don't assume anything
MAGIC FEATURES
- Usually nice, and always fun to code ... but beware
- Two kind of magic : implementation details and Waza
Some no-no :
- Checking callback argument count
- Defining getters with side-effects
- ... Anything which cannot be deduced
CODING STYLE
- More important that you could think
- The best JS documentation is the source code
- You no longer write for your eyes
- Be consistent although flexible : readability comes first
Take it with
a pinch of salt !
(also, my new side-project)