a Stu Penrose presentation
It's hard to do "design by contract" in javascript
Especially painful when refactoring shared code & maintaining mocks/stubs for tests
Tools exist, but they require significant build complexity and/or require the use of another language
We need a simple & easy to use "design-by-contract" mechanism for javascript
client-side only (no server-side mechanisms)
doesn't require build system support
no configuration needed
no globals
works nicely with require.js
Verification that required properties are present & of the right type
Verification of function input and return contracts
looks like javascript
non-invasive; able to be used sparingly, ad-hoc
doesn't force existing javascript code/tools/libraries to work differently
focused on documenting /javascript/ contracts (not copying some other language's constructs)
embraces javascript's "one redeeming feature" (functions)
implemented 100% in javascript
in other words, let's just let javascript be javascript
Function Signatures (arity, argument and return constraints)
Demonstration
Demonstration