As Java programmers we rely heavily on interfaces. We value “design by contract,” where interfaces define contracts for communication and classes implement and abide by these contracts—see Bertrand Meyer’s Object-Oriented Software Construction [Mey97].
Business contracts are good; they help ensure that certain expectations will be fulfilled. However, we don’t want contracts to be too restrictive. We want the flexibility to meet and exceed the expectations in acceptable ways.
Software contracts must be similar. Interface-based programming, although very powerful, tends to be restrictive. Let’s consider an example that highlights the differences between using static typing and dynamic typing.
Say we ...