开发者

Difference between framework and container?

开发者 https://www.devze.com 2023-04-03 07:00 出处:网络
I was reading this question on SO: Framework vs. Toolkit vs. Library where is explai开发者_StackOverflowned difference between framework and library. General opinion is that main difference is in Inve

I was reading this question on SO: Framework vs. Toolkit vs. Library where is explai开发者_StackOverflowned 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.


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.


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).

0

精彩评论

暂无评论...
验证码 换一张
取 消