166. Writing functional interfaces

In this solution, we will highlight the purpose and usability of a functional interface in comparison with several alternatives. We will look at how to evolve the code from its basic and rigid implementation to a flexible implementation based on a functional interface. For this, let's consider the following Melon class:

public class Melon {

private final String type;
private final int weight;
private final String origin;

public Melon(String type, int weight, String origin) {
this.type = type;
this.weight = weight;
this.origin = origin;
}

// getters, toString(), and so on omitted for brevity
}

Let's assume that we have a client – let's call him Mark  who wants to start up a melon-selling business. We shaped the preceding class based on his description. His main goal is to have an inventory application that will sustain his ideas and decisions, so an application needs to be created that must grow based on business requirements and evolution. We'll take a look at the time that's needed to develop this application on a daily basis in the following sections.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.14.141.115