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 eitherAssetAorAssetBdepending on some flag present indataAssetshould also act as a super class in a sense that it's methods should also be present inAssetAandAssetB
I would create a base Asset class and have AssetA and AssetB inherit from it. The factory class should be a separate class - AssetFactory - with just one single responsibility - it should create new Asset object based on some conditions.