background preloader

Javascript Dependency Inversion

Facebook Twitter

Inject by Spredfast. What is dependency injection?

Inject by Spredfast

In a traditional dependency injection paradigm, the container manages objects that are connected to each other through the wiring spec. Injection is done by either setting properties or passing values to a constructor function (which typically then sets the properties on the object itself). While that is a paradigm that works well in object oriented languages, it's more natural in a functional language like JavaScript to inject functions instead.

NOTE: inject-core.js can be used independently of JavaScript MVC. Spredfast/JMVC-Inject. Inversion of Control Containers and the Dependency Injection pattern. In the Java community there's been a rush of lightweight containers that help to assemble components from different projects into a cohesive application.

Inversion of Control Containers and the Dependency Injection pattern

Underlying these containers is a common pattern to how they perform the wiring, a concept they refer under the very generic name of "Inversion of Control". In this article I dig into how this pattern works, under the more specific name of "Dependency Injection", and contrast it with the Service Locator alternative. IOC · cujojs/wire Wiki. Inversion of Control Inversion of Control (IOC) is a general principle of software architecture, that can be applied in different ways.

IOC · cujojs/wire Wiki

The Wikipedia article on IOC says it is where "the flow of control of a system is inverted in comparison to procedural programming. " OSCON 2005 - Dependency Injection - Thank You!