After looking up on the top most of the answers I've found is this:
- High level modules should not depend upon low-level modules. Both should depend upon abstractions.
- Abstractions should never depend upon details. Details should depend upon abstractions.
My understanding on this is that this kind of design violates it? because the class Car depends on the lower level class Engine?
public class Car {
private Engine engine;
public void run() {
engine.start()
// do other stuff
}
}
public class Engine {
public void start() {
// do stuff that will start engine
}
}
If it does violate it, whats the solution? I can't think of an alternative.
Im also having a hard time understanding the second part "Abstractions should never depend upon details. Details should depend upon abstractions."
Aucun commentaire:
Enregistrer un commentaire