A short introduction to a powerful Design by Contract technique and its implementation in ruby contracts.ruby.
Design by Contract allows one to do defensive programming in very elegant fashion, allows to set contracts on methods (expectations on input - arguments; and on output - return result) and invariants on classes. This allows to reason about code much much better.
20. Consistency of input
Consistency of data flows inside the system
Consistency of state of the system
Consistency of output
Blow up loudly on any logical error in the system
24. Benchmark Slowdown
a+b 900% slowdown
production system with network IO 5-10% slowdown
NO_CONTRACTS=1 0% slowdown
No loud blowing up with NO_CONTRACTS=1in production