The SOLID design principles were promoted by http://blog.cleancoder.com/ and are some of the best-known design principles in object-oriented software development. SOLID is a mnemonic acronym for the following five principles: https://stackify.com/solid-design-principles/https://stackify.com/solid-design-principles/ https://stackify.com/solid-design-open-closed-principle/https://stackify.com/solid-design-open-closed-principle/ https://stackify.com/solid-design-liskov-substitution-principle/%20target=https://stackify.com/solid-design-liskov-substitution-principle/ https://stackify.com/interface-segregation-principle/https://stackify.com/interface-segregation-principle/ Dependency Inversion Principle

public interface CoffeeMachine { Coffee brewFilterCoffee(); } public interface EspressoMachine { Coffee brewEspresso(); }

public class BasicCoffeeMachine implements CoffeeMachine { private Configuration config; private Map groundCoffee; private BrewingUnit brewingUnit; public BasicCoffeeMachine(Map coffee) { this.groundCoffee = coffee; this.brewingUnit = new BrewingUnit(); this.config = new Configuration(30, 480); }

public class CoffeeApp { public class CoffeeApp { private CoffeeMachine coffeeMachine; public CoffeeApp(CoffeeMachine coffeeMachine) { this.coffeeMachine = coffeeMachine } public Coffee prepareCoffee() throws CoffeeException { Coffee coffee = this.coffeeMachine.brewFilterCoffee(); System.out.println("Coffee is ready!"); return coffee; }}

Related Articles