June 2018
Intermediate to advanced
280 pages
7h 46m
English
Coffee machines are like façades for the coffee grinders and coffee brewers, because they hide their functionalities. The following code simulates a coffee machine that grinds coffee beans, brews the coffee, and places it in a coffee cup.
The issue, as you will find out from the following code, is that we cannot get fine-sized ground coffee (we have to grind the beans a little longer), since the serveCoffee() method knows only how to make coarse-sized ground coffee. This could be fine for some coffee drinkers but not for all:
package gof.structural.facade;publicclass Main{ publicstaticvoid main (String[] args) throws java.lang.Exception { CoffeeMachineFacade facade = new SuperstarCoffeeMachine(); facade.serveCoffee(); }}class GroundCoffee ...Read now
Unlock full access