3
Let’s say I have the interface Vehicle
:
public interface Vehicle {
void moveForward();
void moveBackward();
void moveLeft();
void moveRight();
}
And the interface LandVehicle
:
public interface LandVehicle extends Vehicle{
void repairTire();
}
If I have a class, say, Car, it is possible that I only implement the interface methods LandVehicle
? Having a standard Vehicle implementation in another class?
For every earthly vehicle will have its own execution of the method repairTire()
, but all will have the same execution of the methods used for locomotion of the Vehicle interface.
My intention is to make an abstraction of the methods used for the database, so that if one day is necessary I can exchange the database without needing to refactor in the classes that already used these methods.
Based on the interface CrudRepository
spring (I cannot use spring in this project). I would have for example:
Usuariorepository <- Mongorespository <- Crudrepository
Is there a reason not to use default methods on the interface or then use to transform the interface into a superclass? If yes which?
– Victor Stafusa
Your problem reminds me of this: https://pt.meta.stackoverflow.com/q/499/132
– Victor Stafusa