Factory Method: shipping parcels

Let subclasses decide which object to create, inside an algorithm the base class keeps.

Level Intermediate

What you will see

  1. Same steps, different parcels
  2. A switch in the middle of the steps
  3. The creator keeps the steps
  4. One method left open
  5. One subclass per carrier
  6. When not to use it

Before / after

Base: factory-method-base-tsView the diff

Exercises