Matt Can Code  

2007 年

OO工程的思想主要体现在服务和接口,
IOC的思想是OO的构想的一个方法论, 强调面向对象的项目特性(面向接口以及面向组件)的管理方式.
并能在部署和运行时调配实现功能.
IOC实现上在运行时才把彼此依赖的实现组织并串联(WIRE UP)起来
强调程序设计中的面向接口设计的概念. 要求程序员以更高的角度设计组件接口,从而适配这些接口的API或类库可以为更多工程重用,成为企业的可复用资源.


2017 年

IOC is a very broad concept, which include Dependency Injection, Messaging accross application boundary or event based development, overall the goal it wants to achieve is loose coupling and put SOLID principles in pratice.

In traditional program model, the flow of work is mainly driven by the main class, one class is doing too much and not adhering to single responsibiltiy pricnciple, take for example, one client and one server is communicating via socket, the client and server each will need to set up the socket connection, and run contineously and infinitely to receive the message from each other. The main thread program is tightly maintianing the control of flow is hence become difficult to extend or lack of flexibility to change

In the sense of Inversion of Control,  the exchange of messaging can be managed by the queue or service bus that help the main thread to focus on one thing which is proccessing the message.

Dependency Injection is subset of IOC decouple the creation of dependency product from the main class / thread which allows the main class focus on what it does and the interface with other layer, leave the creation of object to DI framework. Options for DI include Microsoft Unity, Castle.net etc.

 

Unity IOC

DI will happens in construcotr, for the variable level, use Resolve Locator to get the injection object.

posted on 2007-01-15 16:53  Matt Yeung  阅读(425)  评论(0编辑  收藏  举报