39
loading...
This website collects cookies to deliver better user experience
A coffeemaker
CoffeeMaker
, defining all public behaviour. If we adapt this to Role Interfaces we end up with fig 2:CoffeeMaker
interface. When we created Role Interfaces for the model, we made the roles of Boiler
, Grinder
, Brewer
and Frother
explicit. All of which improve the model.TeaBrewingService
. You could use the CoffeeMaker
interface, since it offers the boil
method, but it also contains three more methods which confuse a client interested in just brewing tea. The Role Interface approach allows that client to use a Boiler
which offers exactly what it needs!Grinder
separately allows the model to support the FancyCoffeeMaker
and the client doesn’t need to change!The granularity of Role Interfaces should be just right
Don’t be like this
39