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

C# DI Func factory without registering Func?

I'm not sure whether SO is the correct place to ask the question, but existing SO questions don't help much(such as Autofac and Func factories), nor does Autofac document help, and google searching autofac factory func couldn't get the answer…
2
votes
1 answer

Dependency Injection - Choose DLL and class implementation at runtime through configuration file

I've an API DLL (API.dll, for example) which, in addition to many other thinks, makes available an abstract class (AbstractClass). Now making use of that AbstractClass I've implemented it on two different dlls: First.API.Implementation.dll with…
Joao
  • 7,366
  • 4
  • 32
  • 48
2
votes
2 answers

Dependency Injection in NuGet package library

This builds on concepts discussed in this question How to manage Castle Windsor dependencies in a nuget library. I am working on a project which uses Castle.Windsor for DI and references several custom NuGet packages. I have installed Castle.Windsor…
2
votes
1 answer

Why is memory utilization continuiously increasing when using dependency injection in a C# console application?

I may know the answer to my posted question: I'm using constructor dependency injection throughout the entire application which is a looped C# console application that does not exit after each request. I suspect the life time of all of the included…
2
votes
1 answer

Swap out repositories with a flag

I have an IRepository< T > interface with many T's and several implementations (on-demand DB, web service, etc.). I use AutoFac to register IRepository's for many T's depending on the kind of repository I want for each T. I also have a…
n8wrl
  • 19,439
  • 4
  • 63
  • 103
2
votes
1 answer

Factory vs PicoContainer - Benefits of IoC Containers

I'm trying to open my mind for fancy IoC principle, and I came across the article: Martin fowler on IoC He provides some examples of using PicoContainer: private MutablePicoContainer configureContainer() { MutablePicoContainer pico = new…
2
votes
4 answers

c# constructor injection and constructor overloads

I'm using constructor injection for the first time and wish to write my code defensively. Therefore if I have a class with a constructor and a save method as below: public SomeConstructor(string name, Object someObject) { _name= name; …
asn1981
  • 237
  • 1
  • 7
  • 20
2
votes
1 answer

Operation is not supported on this platform exception on Xamarin iOS

I am using DryIoC container, and while trying to resolve one of the implementations am getting below error: Operation is not supported on this platform exception on Xamarin iOS The resolve work's fine for the first time, but when I try to call…
Dishant
  • 1,545
  • 12
  • 29
2
votes
2 answers

How best to unit test a ServiceStack service that uses IServiceGateway to call other internal services

I've been following the guidelines here - https://docs.servicestack.net/testing I'm trying to do unit testing rather than integration, just to cut down the level of mocking and other complexities. Some of my services call some of my other services,…
richardwhatever
  • 4,564
  • 5
  • 23
  • 26
2
votes
3 answers

TDD for a Device Communicator

I've been reading about TDD, and would like to use it for my next project, but I'm not sure how to structure my classes with this new paradigm. The language I'd like to use is Java, although the problem is not really language-specific. The…
Nate Parsons
  • 14,431
  • 13
  • 51
  • 67
2
votes
1 answer

In the context of Autofac: What is the difference between a Service and a Component?

What exactly is the difference between a Service and a Component? And how does the extension method RegisterComponent() relate to this definitions? Autofac's glossary defines it as follows: Component A body of code that declares the Services it…
Matthias Güntert
  • 4,013
  • 6
  • 41
  • 89
2
votes
2 answers

How to inject dependencies when those dependencies need a runtime value?

I'm implementing an ASP.NET MVC application and need to implement the Unit Of Work with repositories pattern. My implementation is designed as follows: The UnitOfWork object is in charge of issuing COMMITs and ROLLBACKs as necessary. The…
2
votes
1 answer

Dependency Injection (IoC) in JAVA + Azure Functions

I am using an Azure Function written in Java to retrieve the data from REST API and insert it into the mongo database. I'm trying to separate the app into different layers like I usually do for web applications - for now I've only extracted the…
2
votes
0 answers

Use DryIoC in FreshMVVM

In the README.md of the FreshMVVM repo it is explained which interface has to be implemented to use any other IoC container besides the built-in version of TinyIoC. Is there anyone here who already created a implementation for DryIoC and get it to…
2
votes
1 answer

Providing OSGi Service Without Implementing Interface

Sample 1 @Component(policy = ConfigurationPolicy.OPTIONAL, immediate = false) public class ServiceImpl implement Service { @Override public void foo() { } ... } Sample 2 @Component(policy = ConfigurationPolicy.OPTIONAL, immediate =…