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 ...
Get Programming Groovy 2 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.