3.4 Design by Capability
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.
Using Static Typing ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access