* The dependency inversion principle: depend upon Abstractions. Do not depend upon implementations. 5) What is the motivation behind this principle? - Concretions change much faster. 6) Code a program that reads characters from the input, and then print these characters in the output. public class Control { public void copy(KeyboardInput i, PrinterOutput p) { int d; while ((d = i.readNextKey()) != -1) { p.printData(d); } } public static void main(String args[]) { Control c = new Control(); c.copy(new KeyboardInput(), new PrinterOutput()); } } public class KeyboardInput { public int readNextKey() { return 0; } } public class PrinterOutput { public void printData(int d) { System.out.println(d); } } 6.1) We now have an object called ScreenOutput, which has a method printOnScreen(int). Modify the Controller to handle this object too. 6.2) We now have an object called FileInput, which a method readNextChar(). Modify the Controller to handle this object. 6.3) What is the best design for this problem? * The interface segregation principle: many client specific interfaces are better than one general purpose interface.