zoukankan      html  css  js  c++  java
  • What does IOC stand for? IOC的概念,DI

    http://martinfowler.com/articles/injection.html

    Inversion of Control

    When these containers talk about how they are so useful because they implement "Inversion of Control" I end up very puzzled. 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.

    The question, is what aspect of control are they inverting? When I first ran into inversion of control, it was in the main control of a user interface. Early user interfaces were controlled by the application program. You would have a sequence of commands like "Enter name", "enter address"; your program would drive the prompts and pick up a response to each one. With graphical (or even screen based) UIs the UI framework would contain this main loop and your program instead provided event handlers for the various fields on the screen. The main control of the program was inverted, moved away from you to the framework.

    Forms of Dependency Injection

    The basic idea of the Dependency Injection is to have a separate object, an assembler, that populates a field in the lister class with an appropriate implementation for the finder interface, resulting in a dependency diagram along the lines of Figure 2

    Figure 2

    Figure 2: The dependencies for a Dependency Injector

    There are three main styles of dependency injection. The names I'm using for them are Constructor Injection, Setter Injection, and Interface Injection. If you read about this stuff in the current discussions about Inversion of Control you'll hear these referred to as type 1 IoC (interface injection), type 2 IoC (setter injection) and type 3 IoC (constructor injection). I find numeric names rather hard to remember, which is why I've used the names I have here.

  • 相关阅读:
    菜鸟学freeswitch(二)webRTC拨软电话自动挂断
    热部署神器-JRebel的简单使用
    菜鸟学freeswitch(一)freeswitch安装
    Feign涨姿势的机会
    zuul 设置响应超时
    @Autowired和static的关系
    加固ECS安全性的一些策略
    当https遇上websocket
    Msql 问题(持续更新)
    5.elk
  • 原文地址:https://www.cnblogs.com/wucg/p/2229714.html
Copyright © 2011-2022 走看看