The PEAK Developers' Center   Diff for "InversionOfControl" UserPreferences
 
HelpContents Search Diffs Info Edit Subscribe XML Print View
Ignore changes in the amount of whitespace

Differences between version dated 2005-12-14 20:55:39 and 2007-03-26 18:36:06 (spanning 3 versions)

Deletions are marked like this.
Additions are marked like this.

 
'''Inversion of Control''' (aka '''IOC''') is about breaking dependence between objects by placing interfaces between them. In particular, Inversion of Control focuses on breaking the dependence of ''high-level'' objects on their ''low-level'' modules.
 
Even more specificly, we talk here about '''dependency injection''': When an object is created, it is given its dependencies, rather than making them on it's own. (Another approach is ServiceDiscovery, not described here.)
Even more specificly, we talk here about '''dependency injection''': When an object is created, it is given its dependencies, rather than making them on its own. (Another approach is ServiceDiscovery, not described here.)
 
Traditionally, an object creates the objects it needs. Something like:
 

class Eggs:
 
    def __init__(self):
        self.my_spam = Spam("foo", "bar") # Eggs is creating it's own Spam.
        self.my_spam = Spam("foo", "bar") # Eggs is creating its own Spam.
}}}
 
However, we can invert the control. Instead of creating the object, and perhaps demanding that the environment conform to it's choices, we ''invert control.'' The environment will fetch your dependencies for you.
However, we can invert the control. Instead of creating the object, and perhaps demanding that the environment conform to its choices, we ''invert control.'' The environment will fetch your dependencies for you.
 
{{{
#!python

ExternalControl may have been a better name for the general principle behind "Inversion of Control."
 
-- LionKimbro [[DateTime(2005-04-17T05:04:09)]]
{{{

PythonPowered
ShowText of this page
EditText of this page
FindPage by browsing, title search , text search or an index
Or try one of these actions: AttachFile, DeletePage, LikePages, LocalSiteMap, SpellCheck