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

Performance impact of creating sub containers in Unity 2.0

How costly (performance impact) is creating subcontainers in Unity 2.0? The scenario is for example web application or web service where main container is initialized on start of the application but each processed request has its own instace of…
Ladislav Mrnka
  • 360,892
  • 59
  • 660
  • 670
2
votes
1 answer

How to access class properties through an Interface instance using Unity.WebApi

Is it possible to expose class public properties in different class through IOC. I am creating an instance of Interface but i am not able to access public properties of class. I am using Unity.WebApi for resolving dependencies. TransactionService…
user1263981
  • 2,953
  • 8
  • 57
  • 98
2
votes
2 answers

LinFu IoC Best Practices on High Traffic Websites

We’re in the final stages of putting together a quite high traffic website (approx 6 million page impressions per week) and are using LinFu as the IoC container within the new architecture. We have a pretty standard setup: Web Layer | IServices <-…
Kevin Wilson
  • 7,753
  • 8
  • 35
  • 39
2
votes
2 answers

Guice - what is the equivalent of Spring Autowired in Guice

I am trying to use Guice and I am coming from Spring. I am wondering if @Inject is the equivalent of @Autowired in Spring and if I can use it in web application exactly as I am using it in Spring. Imagine I have a Facade which depends on a service,…
OEH
  • 665
  • 11
  • 29
2
votes
2 answers

Why are Producers not inherited in CDI

Given the following classes private static class ProducedInSubClass { } private static class ProducedInSuperClass { } public static class SuperClass { @Produces public ProducedInSuperClass…
aschoerk
  • 3,333
  • 2
  • 15
  • 29
2
votes
2 answers

Dependency Injection: setting and sharing properties of scoped service in ASP.NET Core

I want to set property in some injected service in controller for later abusing it when this service will be injected in other place during the same request, so I expect this property not to change as far as service is injected as Scoped. Is that…
2
votes
4 answers

Is there a commonly used OO Pattern for holding "constant variables"?

I am working on a little pinball-game project for a hobby and am looking for a pattern to encapsulate constant variables. I have a model, within which there are values which will be constant over the life of that model e.g. maximum speed/maximum…
Grundlefleck
  • 124,925
  • 25
  • 94
  • 111
2
votes
2 answers

how to Resolve circular reference thorough IoC?

Possible Duplicate: Can dependency injection prevent a circular dependency? I am developing a framework which will have various services like dal, integration with sharepoint, exception handling etc. I need to do it in IoC and I am new to this…
2
votes
1 answer

Factory functions in Golang

I have a service object similar to the one shown below which is exposed through HTTP: type ComputeService struct { } func (svc ComputeService) Compute(userType string, data Data) (Result, error) { // rate limit based on userType (both check and…
2
votes
0 answers

Are the words "IoC container" and "DI container" synonyms, or separate concepts?

I'm currently wading my way through articles and questions on the subject of IoC containers, such as: Why do I need an IoC container as opposed to straightforward DI code? What's the difference between the Dependency Injection and Service Locator…
2
votes
1 answer

Explain "Dependency Injection vs Service Location" when using IoC containers

In Jason's answer to Dependency Injection vs Service Location: Right: public Foo(Bar bar) { this.bar = bar; } Is the following sentence true? The point of using IoC frameworks as StructureMap or Unity is, that we can do dependency…
2
votes
1 answer

Using StructureMap[4.7.0] Setter Injection in my MVC5 Controller

I am trying to inject the IApplicationConfigurationSection implementation into this MVC5 Controller, so that I can have access to some of the information (various strings) from my web.config custom section in all of my views: public class…
2
votes
2 answers

Spring DI : Aggregation or Composition

Aggregation: If two objects have there own life cycle and not tightly coupled with each other(can exists independently). Class A { B b; } The default value for b will be null and A's object can exists if there is no instance injected in…
Vicky
  • 1,135
  • 1
  • 17
  • 37
2
votes
1 answer

Spring.NET lacks recursive dependencies resolution?

I'm prototyping a WCF project using Spring.NET as the IoC container. It seems like I have to include explicit references to all Spring.NET managed assemblies I use in my IIS web.config. For example, if my WCF project is referencing Spring.NET…
Hans Gruber
  • 271
  • 1
  • 10
2
votes
1 answer

Idiom for multi-callback structure with variable capture

I have a function which takes an object and invokes various callback functions on it as its output. Example: template void iterateInParallel(vector const& a, vector const& b, T && visitor) { // sometimes invokes…
Sneftel
  • 40,271
  • 12
  • 71
  • 104
1 2 3
99
100