Inversion of Control vs Dependency Injection -
according paper written martin fowler, inversion of control principle control flow of program inverted: instead of programmer controlling flow of program, external sources (framework, services, other components) take control of it. it's plug something else. mentioned example ejb 2.0:
for example session bean interface defines ejbremove, ejbpassivate (stored secondary storage), , ejbactivate (restored passive state). don't control when these methods called, do. container calls us, don't call it.
this leads difference between framework , library:
inversion of control key part of makes framework different library. library set of functions can call, these days organized classes. each call work , returns control client.
i think, point of view di ioc, means dependency of object inverted: instead controls own dependencies, life cycle... else you. but, told me di hands, di not ioc. can still have di , no ioc.
however, in paper (from pococapsule, ioc framework c/c++), suggests because of ioc , di, ioc containers , di frameworks far more superior j2ee, since j2ee mixes framework code components, not making plain old java/c++ object (pojo/poco).
inversion of control containers other dependency injection pattern: http://www.pocomatic.com/docs/whitepapers/ioc-vs-di/
additional reading understand what's problem old component-based development framework, leads second paper above: why , of inversion of control: http://www.pocomatic.com/docs/whitepapers/ioc/
my question: what's ioc , di? confused. based on pococapsule, ioc more significant invert control of objects or between programmers , frameworks.
ioc generic term meaning rather having application, call methods in framework, framework calls implementations provided application.
di form of ioc, implementations passed object through constructors/setters/service lookups, object 'depend' on in order behave correctly.
ioc without using di, example template pattern because implementation can changed through sub-classing.
di frameworks designed make use of di , can define interfaces (or annotations in java) make easy pass in implementations.
ioc containers di frameworks can work outside of programming language. in can configure implementations use in metadata files (e.g. xml) less invasive. can ioc impossible inject implementation @ pointcuts.
Comments
Post a Comment