mardi 9 juin 2015

What is the proper way to use inheritance when combined with factory method?

Given that I have 3 classes Asset, AssetA, AssetB what is the proper way to structure inheritance when using the factory method?

Here is how I would like to use these classes:

  • Asset.new(data) should deterministically create either AssetA or AssetB depending on some flag present in data
  • Asset should also act as a super class in a sense that it's methods should also be present in AssetA and AssetB

Aucun commentaire:

Enregistrer un commentaire