Skip to main content

Posts

Showing posts from April, 2007
Of Hollywood, frameworks, APIs and inversion of control I recently chanced to learn about a pattern called the 'Inversion of Control'. This is primarily used to abstract out the creational part of dependent components from a class is question. In simple terms, a class need not create dependent objects. This independence of the creational logic allows such classes to be more loosely coupled to dependent objects, thus resulting in easy replacement of the dependent objects during run-time. This technique is used by unit-tests to isolate a particular class from its dependencies so that the class / object in question can be tested alone. We usually resort to using creational patterns like the singleton or the factories to decouple the creator from the logic of creation. What we essentially do is, we just add one more level of indirection to the actual creation logic. Earlier, we used to manually use new to create an object. With the singleton, our class uses the singleton, which in