Home - joekrom/demo GitHub Wiki

Welcome to the demo wiki!

How to implement simple Factory design Pattern

  1. Create an Interface for example shape.java
  2. Create concrete Classes implementing the Interface : Rectangle, Circle, Square
  3. Create a Factory to generate or to instantiate object based on the input or the given information the return type of the method should be the parent class, here the Interface. The factory is responsible for determining which Class to instatiate.
  4. use the factory to get an object by passing an information

How to implement the **Builder design pattern **

  1. create a class and generate the constructor(in intellij alt+einfg)
  2. generate the Builder Class using intellij(position the cursor on the constructor, right click and refactor )
  3. you can refactor either using external class or using a created static inner class
  4. create or build an object ex:var device = new DeviceBuilder().setName("rapsberry pi").build(); System.out.println(device);