Saturday, August 23, 2014

Contractually-obligated Testing

Graham Lee:

Having a contract is a bit like having unit tests, except that the unit tests are always running whenever your object is being used. Try out Eiffel; it’s pleasant to have real syntax for this, though really the Objective-C version isn’t so bad.

Finally, the contract is implemented by some simple message interception (try doing that in your favourite modern programming language of choice, non-Rubyists!).

1 Comment RSS · Twitter


The correct way to implement contracts is to integrate them into the language. They need to be easy to write because you should write them everywhere, similar to assertions. Convoluted tricks like this make nice proofs of concept, but are too cumbersome. Nobody is going to use them.

I integrated D contracts with Objective-C objects when working on D/Objective-C a few years ago. Too bad I never really finished D/Objective-C.

Leave a Comment