Dependency Inversion
Java Example
Bad Design (Violating DIP)
class MySQLDatabase {
void connect() {
System.out.println("Connecting to MySQL...");
}
}
class Application {
MySQLDatabase database = new MySQLDatabase();
void start() {
database.connect();
}
}Good Design (Following DIP)
Python Example
Bad Design (Violating DIP)
Good Design (Following DIP)
Last updated