控制反转(Inversion of Control,英文缩写为IoC),也叫依赖注入(Dependency Injection)。我个人认为控制反转的意思是依赖对象(控制权)发生转变,由最初的类本身来管理依赖对象转变为IoC框架来管理这些对象,使得依赖脱离类本身的控制,从而实现松耦合。 实例经典,适合初学者。
对IOC的解释为:“Inversion of control is a common characteristic of frameworks, so saying that these lightweight containers are special because they use inversion of control is like saying my car is special because it has wheels.”
我想对这一概念执行 一个个人的阐述,以方便我的理解。