DSA Factory
Free Design patterns lessonsDesign patterns · Stage 0 · Creating objects · Step 2

Factory

Moving the choice of which class to create out of the caller: the simple factory, the factory method and the abstract factory. About 12 minutes.

Quick check

What does a factory let callers avoid?

  1. AKnowing and depending on the concrete class being created
  2. BAllocating memory
  3. CUsing interfaces
Show the answer

Knowing and depending on the concrete class being created. They use the interface; the factory decides.

Lock it in

4 questions on this idea

Short questions that apply the idea to new cases: trace it, work out a number, put steps in order. A wrong answer explains itself.

Answer them in your browserFree account, no card. Your progress is saved, and the idea comes back in a quick review later.
Sign up free to solve