Functional decomposition is a term that engineers use to describe a set of steps in which they break down the overall function of a device, system, or process into its smaller parts.
xxxxxxxxxx
class FunctionalComposition {
public static void main(String[] args) {
Function<Square, Integer> fun1 = s -> s.getArea();
Function<Integer, Double> fun2 = area -> Math.sqrt(area);
Function<Square, Double> getSide = fun2.compose(fun1);
Square s = new Square();
s.setArea(100);
Double side = getSide.apply(s);
System.out.println(side);
}
}
xxxxxxxxxx
Though you can create a complex program that is wrapped in one solid method or even in a main method, it is better to divide a program into a number of more specific methods that are easy to read and understand. The approach of dividing a complex program into subroutines is called functional decomposition.