2 of 4
clarified use
Why not have a map of types that are instantiated upon Factory initialization?
For example, the values of the map could be instances of BImpl
and DImpl
and the respective keys would be the types, thus avoiding the if/else block. You would just do a map lookup and on the value returned from the map, call BuilderImpl and return the result.
This would also make it easier and more elegant to add more types in the future.
Brady
- 358
- 1
- 10
default