依赖注入与控制反转

spring是依赖规则管理器。和基于依赖的结构的生成器。

依赖关系的描述

依赖的创建

builder模式

由注解和xml来描述依赖关系;

由spring容器来生成依赖实现;

将依赖的描述与实现分离;

spring是依赖规则管理器。

The Inversion of Control (IoC) and Dependency Injection (DI) patterns are all about removing dependencies from your code.

What is Inversion of Control?

If you follow these simple two steps, you have done inversion of control:

  1. Separate what-to-do part from when-to-do part.
  2. Ensure that when part knows as little as possible about what part; and vice versa.

There are several techniques possible for each of these steps based on the technology/language you are using for your implementation.

https://stackoverflow.com/questions/3058/what-is-inversion-of-control?r=SearchResults

2004年,Martin Fowler探讨了同一个问题,既然IOC是控制反转,那么到底是“哪些方面的控制被反转了呢?”,经过详细地分析和论证后,他得出了答案:“获得依赖对象的过程被反转了”。

原文地址:https://www.cnblogs.com/feng9exe/p/11418098.html