Protocop

Runtime, a-la-carte, design-by-contract

a Stu Penrose presentation

The Plan

  1. Problem statement
  2. Definitions
  3. Honorable Mention
  4. Core Protocop
  5. RequireJS Support
  6. Roadmap

Problem Statement

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

Simple & Easy to Use...

client-side only (no server-side mechanisms)

doesn't require build system support

no configuration needed

no globals

works nicely with require.js

... Design by Contract ...

Verification that required properties are present & of the right type

Verification of function input and return contracts

...For Javascript

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

Definitions

Object Protocols

Function Signatures (arity, argument and return constraints)

Honorable Mention

Gozala/protocol ( article, code)

codeparty/protocoljs

toryt

WebIDL

flow (vaporware ?)

Core Protocop

Demonstration

Require.js Support

Demonstration

Roadmap

THE END

by Stu Penrose / engineering.cj.com