Design Pattern Summary

In summary, a classic Factory design pattern looks like this:

  1. You have an interface or abstract class, Worker.

  2. You have some implementations of that, WorkerBill, WorkerJane, WorkerFred.

  3. You have a Factory that has a method, often static, often called getSomething or newSomething.” It returns something of type Worker. That method chooses which of the implementors to use. It does a new WorkerBill (let's say) and returns it as the supertype.

The application code now has a concrete class, but typed as the abstract superclass or interface. It cannot use more methods than are in the interface. Voila.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.141.27