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

Considering Dependency Injection, where should I build objects in nested logical layers?

Let's say I have something like this Controller uses Service. Service has History, Source and HttpClient. Source has SourceRepository and id. Source is only useful for other objects after fetching information from SourceRepository. History has…
Edson Horacio Junior
  • 3,033
  • 2
  • 29
  • 50
2
votes
1 answer

How to properly use IoC container?

I'm very new to IoC idea and I'm trying to jump over the Service Locator pattern. I chose the Kangaru implementation. Suppose I want to use Audio and Logger services in different places of my app. What I have now: #include
qloq
  • 689
  • 1
  • 5
  • 15
2
votes
0 answers

Dyanmic LoggingLevelSwitch Not Working With IoC in .net core

I have an .net core Web API project that uses Serilog for logging. I want to dynamically update the log levels for different classes at runtime. I am using the default IoC for .net core. Some of these classes (like the controllers) are scoped…
2
votes
1 answer

Spring.net - PropertyRetrievingFactoryObject - property is null

In an attempt to resolve this question, I'm taking a look at how our spring.net configuration works. The root problem comes from this snippet:
Jonas
  • 4,454
  • 3
  • 37
  • 45
2
votes
0 answers

What is the proper way to inject internal class with embedded DI mechanism

Can't find proper way to inject internal class from separate library. Found solution for similar problem for Autofac, but can't find same one for embedded dependency injection mechanism. My project structure looks like this: Marketplace (asp.net)…
2
votes
0 answers

How to register type in a container, but resolve in a child container?

firstly, I know there is question with similar title, but either it doesn't answer my case or I do not know how to utilize it (How to register types in the main container, but resolve in a child container?). Basically I wanted to register my type in…
Andy
  • 1,035
  • 1
  • 12
  • 28
2
votes
1 answer

Spring constructor injection shows null When accessing it on methods

I am developing a small application with Struts2 + Spring + hibernate...Spring beans are injected properly on server start-up .. I have stepped through the setters on start up and they are injecting properly. However, I run the post method and then…
Muthu
  • 1,550
  • 10
  • 36
  • 62
2
votes
2 answers

Dependency Injection and user specific data

I have application that uses ORM (Nhibernate but it's not the case). To create NH Session we need to pass somewhere: username, database name, etc. So I have implemented: public interface ISettingsManager { Settings MySettings…
2
votes
1 answer

NestJs runtime injection

I have scinario I implemented before in express app using inversifyjs, I need to implement it using nestjs. I have services(A, B,C) that implement abstact class(Service Abstract) which inheret from the interface (IService). I need to inject one from…
2
votes
1 answer

Replace default IoC container in MvvmCross

Since MvvmCross v7 sticks on its own IoC container, I would like to replace it with the .NET Core one in order to have an easier life when registering third party libraries such as IHttpClientFactory, Polly, Automapper, etc. through already built-in…
Krusty
  • 955
  • 1
  • 12
  • 26
2
votes
5 answers

Unity Framework: How to Instantiate two classes from the same Interface?

I have one interface with 2 classes implementing it, I need to load each class but unity has: m_unityContainer.Resolve() // Where is the interface IGeneric my config looks like:
jerry
2
votes
1 answer

Castle Windsor: How do you add a call to a factory facility not in xml?

I know how to tell Castle Windsor to resolve a reference from a factory's method using XML, but can I do it programmatically via the Container.AddComponent() interface? If not is there any other way to do it from code? EDIT: There seems to be some…
George Mauer
  • 117,483
  • 131
  • 382
  • 612
2
votes
3 answers

could anyone give a simple python for explaining the "Hollywood principle"/inversion of control

I'm very interested in the Twisted web framework. As far as I know the framework uses the Hollywood principle. I just know the term but totally have no idea about this design pattern. I have done a lot of Google searching on the implementation of…
prgbenz
  • 1,129
  • 4
  • 13
  • 27
2
votes
1 answer

How does java IoC framework ensure thread safety?

Recently I have read a great tutorial of Java Memory Model. It says JVM only guarantees the visibility of final field if no synchronization used. Then it occurs to me that when we use some IoC frameworks, we usually use setter injection/field…
2
votes
1 answer

is it possible to do dependency injection that doesn't result in Inversion of Control?

first, I'm new to the software world. so my apologies if this is a simple or bad question. I've been reading about DI and IOC and I understood DI is one way of achieving IOC ( there are other ways as well). so it kept me thinking, does DI always…
Amir S1994
  • 23
  • 3