控制反转与依赖反转本身是十分相似的,但是IOC更进一步要解决Viewer class 直接私有一个shape 对象的例子.
Answering only the first part. What is it?
Inversion of Control (IoC) means to create instances of dependencies first and latter instance of a class (optionally injecting them through constructor), instead of creating an instance of the class first and then the class instance creating instances of dependencies. Thus, inversion of control inverts the flow of control of the program. Instead of the callee controlling the flow of control (while creating dependencies), the caller controls the flow of control of the program.