O'Reilly logo

Programming Groovy 2 by Venkat Subramaniam

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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

Say we ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required