the Stamp Specification
Move Over, `class`:
Composable Factory Functions Are Here
Around that time, I started doing a lot of interviewing to hire developers. That’s when I noticed a huge problem that has only grown in the time since:
misunderstood programming language.”
~ Douglas Crockford
- Prototypal Inheritance
- Functional Programming
I gave a talk on prototypal inheritance at Fluent Conference, 2013: “Classical Inheritance is Obsolete: How to Think in Prototypal OO”. You should watch it before you continue with this article.
Not convinced? Mattias P Johansson posted an entertaining video today which beautifully illustrates the gorilla banana problem with murderous robot dogs:
Classical inheritance creates is-a relationships with restrictive taxonomies, all of which are eventually wrong for new use-cases if they are continually used and evolved. But it turns out, we usually employ inheritance for has-a, uses-a, or can-do relationships.
Composition is more like a guitar effects pedalboard. Want something that can do delay, subtle distortion, and a robot voice? No problem! Just plug them all in:
const effect = compose(delay, distortion, robovoice); // Rock on!
When would you want to use class inheritance? For me, the answer is simple: “Never.”
- More powerful
- More flexible
- More extensible
- Better suited to agile development
The idea seemed to resonate with people, and it wasn’t long before spinoff libraries started to emerge. Notably, Tim Routowicz wrote the excellent React Stampit library for composable React components.
There was just one problem with React stamps: Because they were designed specifically for creating React components, the API was changed to serve that purpose better. React stamps and stampit stamps couldn’t be composed together! Oops.
Today, I’m proud to announce that we’ve been working on a specification that will unite all compliant stamp implementations: The Stamp Specification: Composables. We have three implementations currently in progress:
- A reference implementation with a test suite for implementors
- Stampit 3.0, with a compatability layer for the Stampit 2.0 API
We’ll be working on these implementations in the coming weeks. The goal is to have them done in time for an official announcement and training masterclass at WebDirections in Sydney Australia, October 27th, 2015.
Bonus: You’ll deepen your understanding of functional programming, too.
He spends most of his time in the San Francisco Bay Area with the most beautiful woman in the world.