Say I have a hierarchy of vehicles:
public interface Vehicle { ... }
public class Car implements Vehicle { ... }
public class Bike implements Vehicle { ... }
public class Motorcycle implements Vehicle { ... }
Each concrete vehicle type has its own *Dao, because they must be partially persisted on different tables.
Say I'm working over a List<Vehicle>, what's the better approach to avoid instanceof or switches for selecting the correct *Dao implementation?
I'm not in a DI context.
Aucun commentaire:
Enregistrer un commentaire