1

I was reading this question on SO: Framework vs. Toolkit vs. Library where is explained difference between framework and library. General opinion is that main difference is in Inversion of Control, so you have hot spots in framework where you attach your application functionality (in essence you choose between inheritance/template/heavyweight or composition/strategy/lightweight to achieve that).

Ok, now I am curious what is difference between framework and container then? I saw following definition of container (by Rod Johnson): "Container is framework in which application code/objects runs". And that is what confused me. I thought that it is more or less definition of any framework :) I mean, if you use IoC as parameter that makes difference between library and framework (aka you call library, but framework calls you), then doesn't it mean that more or less any framework satisfy above definition of container?

Thanks in advance.

Community
  • 1
  • 1
Kovasandra
  • 555
  • 1
  • 6
  • 15

2 Answers2

1

Container is full package of os and codes which enables the user or execution model to run. Framework contains all the code needed for particular process.(like in python if we want to create the train test dataset,we have inbuilt code from sklearn).

1

I think you are mixing up the principle of Inversion of Control and an IoC tool.

The main characteristic of a framework is that it follows the IoC principle and calls your code (as explained in the linked thread). An IoC container is merely a tool, not a fullblown framework, to aid you to write cohesive, loosely coupled code following the IoC principle.

In general (at least in .Net) a class Container underlies this tool where the registration/resolving/building up object graph etc. takes place but i believe the name is an historical artifact based on the name PicoContainer and Martin Fowlers article Inversion of Control Containers and the Dependency Injection pattern.

  • I am still confused :) You just introduced another term here: "tool". Ok, can you define a tool? What is difference between your definition of tool, and your definition of framework? When you say "An IoC container is merely a tool, not a fullblown framework, to aid you to write cohesive, loosely coupled code following the IoC principle.", I think that purpose of good framework is also to aid you write cohesive, loosely coupled code following IoC principle :) – Kovasandra Sep 06 '11 at 10:12
  • A tool is a piece of software that helps you to develop. So every framework can be called a tool. In this sense tool means a very small framework.A good framework is one that fullfills it's purpose but doesn't automatically help you write loosely coupled code. For instance NHibernate is good at managing persistence but does it help you automatically write good code? I think not. An IoC tool/framework's purpose is to loosely couple your code – Jan Christian Selke Sep 06 '11 at 11:05
  • Of course, Hibernate does not automatically means your code is cohesive and loosely coupled, but it gives you an relatively easy option to achieve that your persistence related code is cohesive and loosely coupled. No framework will make your code cohesive and loosely coupled automatically, but its purpose is to give you easy way to do it. Even if you use spring, for example, your code can be tightly coupled with IoC container if you don't use it the right way :) So, if I understood you correctly, you think that container/tool is in some sense just a small framework? – Kovasandra Sep 06 '11 at 11:21
  • A tool is a small framework, a Container is as well the central class of a IoC specialized tool/framework as the tool/framework itself. – Jan Christian Selke Sep 06 '11 at 11:32
  • Ok, that is what I wanted to hear :) Thanks. – Kovasandra Sep 06 '11 at 11:52