Questions tagged [inversion-of-control]

Inversion of control (IoC) is an abstract principle describing an aspect of some software architecture designs in which the flow of control of a system is inverted in comparison to procedural programming.

In traditional programming the flow of the business logic is controlled by a central piece of code, which calls reusable subroutines that perform specific functions. Using Inversion of Control this "central control" design principle is abandoned. The caller's code deals with the program's execution order, but the business knowledge is encapsulated by the called subroutines. In practice, Inversion of Control is a style of software construction where reusable generic code controls the execution of problem-specific code. It carries the strong connotation that the reusable code and the problem-specific code are developed independently, which often results in a single integrated application. Inversion of Control as a design guideline serves the following purposes:

  • There is a decoupling of the execution of a certain task from implementation.
  • Every system can focus on what it is designed for.
  • The systems make no assumptions about what other systems do or should do.
  • Replacing systems will have no side effect on other systems.

Dependency injection and Inversion of Control are closely related. The difference between them is discussed in this question.

Wikipedia: Inversion of Control

Related Patterns

4379 questions
2
votes
1 answer

How to handle a list of views with IOC

If I have a collection which contains a list of models and want to create corresponding views for each model, what is the best way to do this using IOC (inversion of control)? I see two ways: Use a factory pattern. I would only pass in my model…
Nick Lang
  • 859
  • 2
  • 9
  • 15
2
votes
1 answer

Basis of Dependency injection framework

I want to write my own simple DI framework. I want that it perform only this simple case like Spring does: public interface IWriter { public void writer(String s); } @Service public class MySpringBeanWithDependency { private IWriter…
itun
  • 3,439
  • 12
  • 51
  • 75
2
votes
2 answers

Ioc container placement within enterprise application

I've been looking into Ioc containers and AOP recently, and I'm pretty amazed by the concepts. I'm struggling however to decide how and where to implement the container. The articles below suggest implementing the container in the 'application…
Jochen van Wylick
  • 5,303
  • 4
  • 42
  • 64
2
votes
2 answers

Ninject InSingletonScope() view model isn't assigned to a view at binding

I am assuming that when in NinjectModule I bind Bind().ToSelf().InSingletonScope(); an instance of SplashViewModel is being kind of a cached in Ninject kernel and each time I call kernel.Get I would be getting the…
Maxim V. Pavlov
  • 10,303
  • 17
  • 74
  • 174
2
votes
1 answer

Unity 2.0 IOC Configuration about Generic class

I want some Repository class extend one common generic class to perform some common operation, problem is: how to config a UserExRepository type in config file. public class UserExRepository : Repository, IUserEx { public…
2
votes
1 answer

how to use latest castle windsor wcf integration facility

I'm playing around with Castle WCF integration facility because I want to integrate my WCF services with windsor IOC. The issue I'm facing is that I can't set IKernel for DefaultServiceHostFactory. I setup the container: container = new…
2
votes
1 answer

Custom OptionalAttribute with Ninject

Is there a way that I can create my own OptionalAttribute for Ninject? I know I can replace InjectAttribute by using the NinjectSettings class (which I already have done), but there doesn't seem to be any option for the OptionalAttribute.
Daniel A. White
  • 187,200
  • 47
  • 362
  • 445
2
votes
1 answer

StructureMap, Entity Framework, and IRepository/IUnitOfWork Configuration

I'm using StructureMap with Entity Framework and IRepository/IUnitOfWork patterns on an ASP.NET MVC app. The goal is to have all of the objects scoped to the current HTTP request, as follows: For() .HttpContextScoped() …
2
votes
2 answers

IoC Register Instance Issue with MVC3, Unity & NHibernate - (Unity.MVC3 lib from codeplex)

I'm using the Unity.MVC3.dll from codeplex and am attempting to register an instance of a NHibernate ISession per request. As per the Unity MVC3 docs I should just have to use the HierarchicalLifetimeManager to accomplish this: var container = new…
2
votes
2 answers

Unity: default and conditional resolving

A. Simple question. I have 3 instances of "Repository" that depends on the "Configuration". class Manager{ public Manager(Configuration conf){ ... Resolving strategies for 3 instances…
2
votes
3 answers

.NET IoC: Configure library components from (application) composition root

I have a library handling interactions with a database backend that I use in most of my applications and now want to convert to an IoC structure (using Autofac internally, but its usage should not depend on a specific IoC container or even on using…
TeaDrivenDev
  • 6,591
  • 33
  • 50
2
votes
1 answer

WPF + IoC: "Specified Visual is already a child of another Visual or the root of a CompositionTarget."

[Edit: Rethinking architecture along mvvm lines made this problem largely fall away - thanks @kent] Using Spring.NET + WPF. Load two WPF buttons in the config:
Jeffrey Knight
  • 5,888
  • 7
  • 39
  • 49
2
votes
1 answer

IoC Containers, WCF & ServiceHostFactories

I have been reading about IoC lately, and I think it would definitely come in handy in the WCF web-service I am developing. However, it seems that Ninject, StructureMap and Spring.Net (I only did check these three) require the custom Factory…
DotNetStudent
  • 889
  • 9
  • 24
2
votes
1 answer

MEF vs Unity mostly for Composition

I'm creating a multi layer project with a lot of different assemblies and using dependency injection. I was thinking about using some tool for composition but not sure which one to use. MEF and Unity are strong candidates. I think that MEF could…
Ingó Vals
  • 4,788
  • 14
  • 65
  • 113
2
votes
1 answer

.Net Runtime Assembly Binding

I have a rather unusual problem and need some ideas. I maintain two codebases that are 99% identical. A new project has come along that under some runtime condition needs to use code base A and in other conditions use precompiled code base B. I have…
Slappy
  • 4,042
  • 2
  • 29
  • 41