Difference IoC container and Factory pattern

原创 2012年03月30日 15:43:18

   1 I would suggest to keep the concepts plain and simple. Dependency Injection is more of a architectural pattern for loosely coupling software components. Factory pattern is just one way to separate the responsibility of creating objects of other classes to another entity. Factory pattern can be called as a tool to implement DI. Dependency injection can be implemented in many ways like DI using constructors, using mapping xml files etc.

    2 Inversion of Control (IoC) and Dependency Injection (DI) usually refer to the same thing. IoC is a more general concept (instead of doing X itself, a class relies on some other class to do it) DI is IoC as applied to dependent classes (instead of creating a class that I depend on, it will be passed to me). DI is the most common use of IoC, so usually when they are discussed the terms are used interchangeably.

The Factory Pattern's main concern is creating things - DI's main concern is how things are connected together.

In practice, these two concerns (creating and connecting) are usually related, so most DI/IoC containers do both. You could think of most implementations as very configurable factories - but because the implementations address both concerns - not because the Factory pattern and DI/IoC are the same.

Introduction to the Spring IoC container and beans

3 The IoC container(IOC容器)3.1 Introduction to the Spring IoC container and beans(Spring IOC容器与beans的...

抽象工厂的初次尝试 ((15c++ Homework) polymorphic and OOP design pattern Abstract Factory)


小谈抽象工厂模式与工厂方法,Abstract Factory Pattern and Factory Method

  • gusgao
  • gusgao
  • 2016年08月10日 22:59
  • 268

MVC or MVP Pattern – Whats the difference?

Over the years I have mentored many developers on using design patterns and best practices. One ques...
  • jzp_cn
  • jzp_cn
  • 2011年05月29日 15:33
  • 729


  • 2008年11月06日 10:48
  • 41KB
  • 下载

Difference between ScrollView and ListView

初学Android的时候曾经遇到过在ScrollView中使用ListView的情况。在ScrollView中使用ListView会出现的情况就是你在使用的时候会出现滚动不协调的情况。 下面就是一般对...
您举报文章:Difference IoC container and Factory pattern