February 2014
Intermediate to advanced
160 pages
4h 59m
English
We’ve been looking at the internals of methods and classes in this chapter. Now let’s shift our focus to see how lambda expressions can help shape a class’s skin or interface. We can use these techniques to structure the API of our classes, to make it more intuitive and fluent for programmers to use.
Let’s start with a simple Mailer class and evolve the design of its interface.
| designing/fpij/Mailer.java | |
| | public class Mailer { |
| | public void from(final String address) { /*... */ } |
| | public void to(final String address) { /*... */ } |
| | public void subject(final String line) { /*... */ } |
| | public void body(final String message) { ... |