I have legacy code and my task to refactor it.
- There is base class (ie vehicle)
- it's heirs (car, bus, motorcycle and so on)
- Service that has to choose and greate instance appropriate heir by parameter
So I've something like this:
...
if (param == "car")
result = new Car();
else if (sectionType == "bus")
result = new Bus();
else if (sectionType == "motorcycle")
result = new Motorcycle();
...
I think that code isn't productive and supported.
Q: My aim is founding out the better design solution.
Thx in advance
Aucun commentaire:
Enregistrer un commentaire