realist

The common belief is that you are either a dreamer or a realist. But idealism and pragmatism aren't as far apart as one might think. -— Bill de Blasio

Design by Contract

Design by Contract is one of those ideas that I bumped into in the late 90s that seemed really sensible when I first heard it.

I had fallen hard for Objects and really couldn’t see the world in any other way. Cooperating components, interacting across boundaries, whether that was classes in a program (like with Java or C++) or binary objects distributed across a system like Microsoft’s COM.

DbC offered an approach to securing those components by being incredibly strict about what they would accept, why they would provide, and about which parts of the world they’d leave exactly as they found it.

We started to use some DbC in the Java we were working on at Panasonic and found it incredibly helpful.

Then, in 1999, we discovered TDD.

Very quickly it became clear that testing was essentially duplicating the work we were putting into postconditions and invariants, as well as confirming our preconditions were correctly set up.

With a TDD approach I’m not sure its worth taking the time to add all the postconditions and invariants quite so explicitly.

Of course in a more COM-like situation where you can’t guarantee that you wrote the code that’s calling you, these things still make a ton of sense for locking down exactly what a client can expect from calling into your object.