I am learning SOLID principle. While learning “Dependency Inversion Principle” found out that class should depend on interfaces rather than concrete classes.
Does this mean composition is not allowed? Also, does aggregation same as DIP?
Composition:
`class HPDesktop {
private BluetoothMouse bluetoothMouse;
private BluetoothKeyboard bluetoothKeyboard;
public HPDesktop(){
bluetoothMouse = new BluetoothMouse();
bluetoothKeyboard = new BluetoothKeyboard();
}
}`
DIP: (This seems to be as an aggregation)
`class HPDesktop {
private Mouse mouse;
private Keyboard keyboard;
public HPDesktop(Mouse mouse, Keyboard keyboard){
this.mouse = mouse;
this.keyboard = keyboard;
}
}`