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

Is this plugin framework IoC/DI?

I am working on a way for my ASP.NET C# application to allow plugins without recompiling the host application when new plugins are installed. Here's my plugin loader class (based on tutorials found online.) public class PluginLoader { public…
quakkels
  • 11,676
  • 24
  • 92
  • 149
2
votes
2 answers

Ninject WCF Error

OK, I'm at my wits end after hunting this error down for the past two days: Error activating IUserIssueRepository No matching bindings are available, and the type is not self-bindable. Activation path: 2) Injection of dependency IUserIssueRepository…
Didaxis
  • 8,486
  • 7
  • 52
  • 89
2
votes
1 answer

java.lang.IllegalStateException: Cannot deserialize BeanFactory with id org.springframework.web.context.WebApplicationContext

i am using spring 3 with JSF 2, Tomcat 6 and i replaced JSF managed beans with spring beans, by adding on top of bean: @Component("mybean") @Scope("session") and in my bean i am autowiring a spring service (which was declared with the annotation…
2
votes
1 answer

Using ninject (DI) to instantiate a presenter with webforms and MVP

I've got a webforms app that I'd like to use dependency injection on. I realize that I can't use DI to construct the each Page because webforms doesn't have the proper hooks like aspnet MVC does. Nate Kohari suggests on the ninject mailing list…
viggity
  • 15,039
  • 7
  • 88
  • 96
2
votes
4 answers

Ninject + ASP.NET Web Forms Not Working

I've successfully implemented Ninject in an MVC3 application, but am running into some trouble doing the same thing with ASP.NET Web Forms. I'm getting null references every time I try to access an injected property in my business layer. After…
Scott
  • 13,735
  • 20
  • 94
  • 152
2
votes
0 answers

Using inversifyjs to inject container bindings to an instance of an existing object

Basically I would like to be responsible for the construction of the object, then use inversify to bind properties that are decorated to @inject. I thought I could use createChild to bind the type to a value using toConstantValue or even…
csharptest.net
  • 62,602
  • 11
  • 71
  • 89
2
votes
1 answer

Inject different implementation based on yaml configuration

Using python package dependency injector, I need to instantiate/inject a different implementation of an interface based on a yaml configuration file. class SomeInterface(abc.ABC): @abc.abstractmethod def some_method(self): …
David Clarke
  • 12,888
  • 9
  • 86
  • 116
2
votes
1 answer

Is it possible to use C# DataAnnotations with IOC containers?

Is it possible to use C# DataAnnotations with IOC containers? I've got a ValidationAttribute that I'd like to inject a resolved object into the attribute class after the class is instantiated. Basicly, I want to access an annotation from an…
user297691
2
votes
1 answer

`Send` is not implemented when attempting Inversion of Control in Rust

Summary When trying to have a tonic server class depend on a trait, I get a compile-time issue about the trait not implementing Send or Sync. My intent is to have the server class depend on the trait rather than the concrete implementation of that…
2
votes
1 answer

How to inject one DotNet Core 3.1 Class library project into another DotNet Core 3.1 Class library project

I want to inject an interface(s) of my DAL project (Core 3.1 Class Library) into my Bll Core 3.1 Project. From reading, it seems I need to use the activator Utility? Is this the case or am I wrong in my assumption? How Would I do this…
2
votes
1 answer

How can I pass objects to ViewModels using NavigationService?

The project I am working on is a desktop based WPF application. I have implemented the MVVM pattern in it. Also I am using Unity IoC and the Repository Pattern in it. I have a problem in a master details type scenario. I navigate to the details…
Shoaib Shaikh
  • 4,565
  • 1
  • 27
  • 35
2
votes
2 answers

Why so many terms to say the same thing? IoC and DIP

IoC = Inversion Of Control DIP = Dependency Inversion Principle (D in S.O.L.I.D.) IoC == DIP? I think so, is true. The world of building software is already so messy, why so many words to say the same thing? (I know DI (Dependency Injection) and it…
Acaz Souza
  • 8,311
  • 11
  • 54
  • 97
2
votes
1 answer

How to mock ILogger only once, without needing to create a new mock for every generic T implementation?

TL;DR: As mocking open generic types isn't possible with Moq, creating actual mock is inescapable. Here's the bare minimal mock I ended up using: internal interface ILoggerMock { public List<(LogLevel logLevel, string msg)> Logs { get;…
Tar
  • 8,529
  • 9
  • 56
  • 127
2
votes
2 answers

Strategies for Organizing Dependencies/IOC Containers in an MVC3 .Net app with Castle Windsor

So, I'm new to using Castle Windsor and I'm struggling with how ugly my Controllers are becoming. I've got IOC working in my project which seems to be at least half the problem for most people. Now I'm finding that I'm declaring a ton of…
2
votes
1 answer

Suggestions for "Blendable" ViewModelLocator with Unity 2.0

I have an suite of existing Silverlight applications using the MVVM pattern to separate Views and ViewModels. We use Unity 2.0 for an IoC container to inject dependencies into the ViewModel classes (and supporting types). I have an existing…