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
4 answers

Having overload methods that use IoC container

I am writing a API over the top of a COM object and you have to pass around the COM object into pretty much every type and static method that I write so that I can test each part of my API. Now my question is do I have an overloaded method for the…
Nathan W
  • 54,475
  • 27
  • 99
  • 146
2
votes
1 answer

Castle Windsor Register Component by Convention

I want to implement auto-registration for my repositories, which follow this convention: Repositories implement IRepository There is an abstract class which implements IRepository, for example: UserRepository The actual implementation ends in the…
bevacqua
  • 47,502
  • 56
  • 171
  • 285
2
votes
1 answer

selectively resolve dependencies of same interface in unity

We are using Unity framework for Dependency injection. I am registerring two concrete implementations for same class. like... container.RegisterType("first"); container.RegisterType
bhavesh lad
  • 1,242
  • 1
  • 13
  • 23
2
votes
2 answers

Handling cross-cutting concerns like internal statistics reporting for components of a web application

I am trying to implement statistics reporting for internal components of an OLTP web application. For example, I want to track near real time the usage or performance of things like: number of successful/failed logins, number of nhibernate sessions,…
2
votes
2 answers

Property injection and setting properties on the injected type

If one uses property injection how do you set properties on that type? For example public class MyClass { public ITimer MyTimer {get;set;} } We can use DI to resolve ITimer but how/where do we define property values for ITimer, for example, if…
Jon
  • 38,814
  • 81
  • 233
  • 382
2
votes
1 answer

How do I define constructor argument to take custom object with ninject?

How do I pass an object to a constructor argument with Ninject? Assuming the object is register in the container.
Nick
  • 19,198
  • 51
  • 185
  • 312
2
votes
1 answer

How to get an instance of unitycontainer?

I've developing a Silverlight application, and I've introduced Unity into it. The problem I have is I don't know how to get an instance of container. I create this intance in ApplicationStartup method on the App _container = new UnityContainer(); …
user278618
  • 19,306
  • 42
  • 126
  • 196
2
votes
1 answer

How do I tell MEF which type I need for this interface?

I have following: public interface IEmailService { bool SendEmail(MailMessage message); } [Export(typeof(IEmailService))] public class SmtpEmailService : IEmailService { } [Export(typeof(IEmailService))] public class…
katit
  • 17,375
  • 35
  • 128
  • 256
2
votes
2 answers

Serialization vs ctor injection and protecting invariants

I could be missing something obvious here... But as I learn to appreciate the glory of IoC and ctor injection I am having trouble reconciling this with object graph serialization. Are the two patterns compatible? Why (or why not)? Suppose there…
2
votes
0 answers

Spring .net 1.3.2 Vs Castle Windsor Vs Other IoC Containers

Possible Duplicate: How do the major C# DI/IoC frameworks compare? I am currently about to start a new project and I need a little help in choosing an IoC container that is robust, highly tested and is likely to be around for the foreseeable …
2
votes
1 answer

Datasource, Repository, ViewModels and IoC Container. Is a Repository really needed?

I current got a flow like this: The Repository gets injected with a Datasource. The ViewModel gets injected with the Repository. Because there's a constant flow of Items and Mutations (deletions, changes) that need to translate to the UI I don't…
2
votes
1 answer

Shouldn't an IoC container be handling serialization of business logic singletons?

The statements and a following question below are based on my own experience, and if some are incorrect, you are free to point it out. In fact, I would really appreciate it. In almost any application architecture, a developers make use of an IoC…
2
votes
1 answer

IOC (simpleServiceLocator) setup testing with Specflow and WatiN

I have some acceptance tests using Specflow and WatiN but am not sure where to setup up my registrations for my IOC container (SimpleServiceLocator). In my web site, the registration is done my global.asax. In my test project, I've tried setting…
2
votes
1 answer

Unity container loses registrations when used in tests

I'm working with a team that have had problems with random failing tests. The failing tests seemingly only failed on the buildserver (TFS). But as I investigated the problem I was able to have them fail on my local machine as well. It seems that I…
jand187
  • 296
  • 3
  • 14
2
votes
2 answers

Spring dynamic object inject - @Autowired

imagine one dao class and one service(BO) class . how to automatically inject FwObject to setFwObject method , because FwObject having user related information and these piece of code should be written inside framework Class MyAction exdends…
Arun
  • 1,167
  • 18
  • 37