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.

Filter by
Sorted by
Tagged with
0
votes
1answer
60 views

How far we have to consider the plug-ability while designing an email service using external library

I was designing an email service in .net standard 2.0 using mailkit library. I proposed the following design This design was not accepted stating the following reasons: This design have to many ...
0
votes
0answers
63 views

Instantiating adapters in onion architecture

GitHub and NuGet Do you use connection strings to instantiate your adapter services or just always configure it through IoC? I think that connection strings could provide a way more flexibility, ...
2
votes
1answer
78 views

What's the difference between Strategy Pattern and IoC

In both the Strategy Pattern and in Inversion of Control you can exchange parts of an object that allows scalability and easy-to-exchange parts. I am referring to this and this Both use an interface ...
1
vote
2answers
107 views

How to configure and setup an IOC Container for a library?

When using Dependency Injection across internal classes (implementation details) in a library which is to be consumed by multiple applications, is there a good way to configure the IOC container? ...
0
votes
1answer
179 views

IoC/DI + “normal” constructor arguments mvvm

I am using unity in C# to achieve dependency injection and inversion of control. What if I have a class, let's say a viewmodel, that depends on several services like a repository, a validator and a ...
2
votes
2answers
310 views

Does SOLID Require an IoC Container (Automatic Factory)?

The fifth concept in the SOLID principle is the dependency inversion principle. It is heavily related to dependency injection, and Inversion of control, and when any of these concepts are mentioned, ...
1
vote
1answer
108 views

How to define Composition Roots for libraries (Javascript/inversify)

I'm building a console app (A), which depends on library B. Library B further depends on library C. I am building all 3 entities. Most of the development completed so far has been done using a ...
0
votes
2answers
201 views

Passing runtime-read configuration when working with an IoC container

I've recently "discovered" the IoC realm, and decided to refactor a project I'm working on to use such a container. To be specific - I'm using autofac in C#, in a .NET Core console application. The ...
0
votes
0answers
98 views

How to setup up a background thread/task which triggers UI updates?

Background I'm designing a round-based game where one of the core design goals is to have a highly exchangable UI. For this, I've defined an interface which allows implementers to only focus on ...
2
votes
1answer
48 views

Where does the responsibility for clearing higher-level caches lie in a pyrimidal calculation system with caching at multiple levels?

I'm working on system that analyses non-trivial amounts of data. The analysis is pyramidal, in that various combine to make intermediate values, which in turn combine with each other and more inputs ...
0
votes
0answers
97 views

Is using IoC with data classes a good practice

I usually use IoC frameworks to inject dependencies that are services. Is it ok to mark classes that are data objects as IoC components? To be more clear I will give an example. I have an abstract ...
1
vote
2answers
93 views

In some IOC contexts, could constructor of polymorphic immutable object be required in its interface?

Generally, constructors in an interface are considered as being an anti-pattern. Some languages even don't allow that. Then I don't understand how we're supposed to deal with polymorphic immutable ...
3
votes
2answers
479 views

Passing DI container to a factory – is this always an antipattern?

Generally I would always answer "yes" to this question, because at this point, your DI container has become a service locator, and you're losing the benefits of DI. However, I wonder if it is ...
0
votes
1answer
121 views

Evaluation of (a)synchronous design of ledger interface

I'm currently designing a ledger API, that should work with different implementations (e.g. based on Blockchain, traditional databases, or files). Its purpose is to add/get messages to/from a ...
0
votes
1answer
88 views

Is Dependency Injection A Standard in PHP and Laravel?

Or in actuality, how to tell if a certain technique has became a standard in certain language / framework? As I understood from my readings so far, PHP supports DI in PSR-11 while Laravel uses it out ...
4
votes
5answers
2k views

How can you use DI without DI framework in a reasonably complex project?

edit I asked this question not because this is my opinion, but because I am trying to understand someone else's. Personally I prefer IoC via DI (in my specific case Simple Injector) but not everybody ...
-2
votes
1answer
235 views

Why EJB service Injection requires the specific subclass to be created?

Most Java EE guidelines suggest that we should define Abstract EJB services (APIs) and then define concrete implementations in order to conform with OO design principles. But at the injection point, ...
4
votes
2answers
106 views

Simple examples of properly designed Asp.Net applications illustrating different service layers?

I've been programming professionally for years now at several different companies and I consider myself to be a fairly competent programmer. However, of everywhere I've worked there are usually dozens ...
14
votes
3answers
5k views

Is Poor Man's Dependency Injection a good way to introduce testability to a legacy application?

In the past year, I created a new system using Dependency Injection and an IOC container. This taught me a lot about DI! However, even after learning the concepts and proper patterns, I consider it ...
2
votes
3answers
415 views

IOC container & accessing Implementation from the container

Background As mentioned in this article, Inversion of Control can be achieved through various mechanisms such as: Strategy design pattern, Service Locator pattern(SLP), Factory pattern, and ...
18
votes
2answers
1k views

Is there evidence that the use of dependency injection improves outcomes in software engineering?

Notwithstanding its popularity, is there any empirical evidence that shows that Dependency Injection (and/or using a DI container) helps with, say, reducing bug counts, improving maintainability, or ...
2
votes
0answers
722 views

Dependency Injection: Creating object factories vs. using inversion of control containers [closed]

When requiring to use dependency injection, I always use IoC containers such as Ninject, Unity, or the built-in one in ASP.Net Core MVC. However, I've just come across the idea of "why not creating an ...
2
votes
1answer
70 views

Responsibility for adding and ordering menu items in a modular application

Following Ordering menu items fed from multiple modules the question was raised to me, who is responsible for ordering and alignment of menu items in a modular application. The previous link suggests ...
1
vote
2answers
128 views

IoC configurations - one file/assembly in solution or one file per executing assembly?

We're wondering what the best practise for registering types in a IoC-Container is. What would be arguments for and against the following principles: Principle 1: Only one Assembly my.project....
5
votes
4answers
1k views

How to pass data between objects when an IoC container is being used?

I'm working with a project that our architect has decided to use dependency injection for almost everything. We use an IoC container. One of the main issues that I keep coming across when using this ...
0
votes
2answers
3k views

Using generics for dependency resolution constraints

I have such problem: the interface with no in and out parameters. public interface IIndexer { void FillIndex(); } It should work differently for different kinds of activities( comments, likes ...
3
votes
1answer
284 views

What is the generic implementation of design pattern IoC coupled with Factory for DAO? [closed]

I'm learning the java Spring framework. So far, I understood that Spring will make stuff transparent with its configurations so that IoC and Factory are not too complicated to implement... Now I have ...
1
vote
1answer
2k views

Service locator vs Dependency Injection?

I have a class which acts as a Adaptor between an HTTP request and our Application's custom domain request. So every Http request element: URI, headers, content are mapped to our customized domain ...
1
vote
4answers
890 views

Image processing - Service locator pattern & Container of dependencies

As per wiki, A dependency is an object that can be used (as a service). here is the OOP paradigm using C syntax that address 4 roles, shown below. 1) interface (handlers.h) typedef struct { ...
0
votes
2answers
626 views

How to create a factory method

Say I have a Business class called person: public class Student { } Say I want to create a factory method for this Student class - something like this: public Student getStudent(string studentType) ...
8
votes
2answers
13k views

Dependency injection for a library with internal dependencies

Background I am working on a class library in support of a web site. The library combines related APIs from several different vendors, all of which have their own particular nuances and domain ...
4
votes
3answers
1k views

DependencyInjection - Constructor over-injection smell vs service locator - where is the proper approach?

I am trying to improve my MVC projects and I read a few articles about DI, IoC containers, Constructor Injection and Service locators. I wanted to go with Ninject to help with the dependencies, but ...
6
votes
3answers
2k views

How do I support per-method-call instantiation without referencing the IoC container outside the composition root?

I read with interest this article which states: A DI Container should only be referenced from the Composition Root. All other modules should have no reference to the container. This means that ...
5
votes
3answers
147 views

Passing database connection to the library

I'm writing java library(jar file) to log Web service request and responses in a Database for in-house application. This library will have two methods registerReuqest and registerResponse. I'm ...
1
vote
0answers
134 views

Inversion of control in controller by a mediator

A user has to perform a somewhat complex task on my website (submitting a rating). For the sake of example, let's consider it's a rating for a movie, done through a controller. There are several ...
14
votes
5answers
4k views

Using Func instead of interfaces for IoC

Context: I am using C# I designed a class, and in order to isolate it, and make unit testing easier, I am passing in all its dependencies; it does no object instantiation internally. However, instead ...
7
votes
3answers
578 views

Is it good practice to register development mocks using conditional compilation?

I'm developing an application that connects to a database, and I'm using DI/IOC. When running the entire application while developing, I naturally want to avoid hitting the DB. Currently, I have ...
4
votes
1answer
219 views

Does an IoC Container affect the design of an application using Dependency Injection?

Is it safe to say that a Container is the "program" or mechanism that manages IoC via DI, but it doesn't really change your initial design of DI to accomplish loose coupling? In other words, if I ...
1
vote
0answers
426 views

Opening new Window from ViewModel using Castle Windsor

I've been following the quick tutorial on using Castle Windsor in MVVM WPF: TUTORIAL I've set everything up (as for the basics) but I came to the point of creating a new Window after a button click. ...
1
vote
1answer
451 views

Implementing IoC the right way

I started working in a project around 3 months ago and since I joined I saw so many mistakes in the whole design - the architecture is completely dysfunctional and badly implemented and a lot of used ...
2
votes
2answers
468 views

IoC Framework vs. DI Layer

Say we have a class structure like the following: // implementation.ts export class A implements IA { constructor(private b: IB) {} } export class B implements IB { constructor(private c: IC) ...
0
votes
1answer
238 views

How to use dependency injection for applications that are configurable at startup?

I'm writing software that needs to be fairly configurable in nature. At this point what that means is that it first reads in a users configuration file and then builds the objects it needs based on ...
21
votes
7answers
15k views

What is the “right” way to implement DI in .NET?

I'm looking to implement dependency injection in a relatively large application but have no experience in it. I studied the concept and a few implementations of IoC and dependency injectors available, ...
3
votes
4answers
2k views

Class Library - How to communicate between objects that are not aware of each other?

I am trying to improve my programming skills and knowledge and I have been doing some reading about various design patterns and youtubing videos etc. One subject I thought was interesting was about ...
3
votes
1answer
812 views

IoC, Unity: Creating a component with additional concrete parameters

I am struggling with the following issue. Let's say I have a component that performs operations on guests and rooms, and uses a number of abstract interfaces, along the lines of: class HotelManager { ...
4
votes
3answers
558 views

Missing dependencies at compile-time with IOC

Thanks to my new job, I recently discovered the inversion of control design principle (with windsor castle in C#). I really enjoy using it but something's bothering me. For me the good part about ...
7
votes
2answers
3k views

Service-locator anti-pattern alternative

I'm using Unity as IoC with C#, but I guess the question really isn't really limited to Unity and C#, but IoC in general. I try to follow the SOLID-principle, which means that I got very few ...
3
votes
2answers
2k views

Dependency injection use in “Clean Code” by Robert Martin

In Robert Martin's Clean Code, I encountered the following method on p. 195: private void parseSchemaElement(String element) throws ArgsException { char elementId = element.charAt(0); String ...
6
votes
4answers
1k views

How does a Dependency Injection/IOC Container know which implementation to use?

When you use an IoC container, like so: var svc = IoC.Resolve<IShippingService>(); How does the IoC Container choose which implementation of IShippingService to instantiate? Further, if I am ...
11
votes
1answer
3k views

How is Inversion of Control related to Dependency Inversion

In many articles all over the web the terms Inversion of Control and Dependency Inversion Principle seem to be mixed up and used as synonyms (further confusion is enforced by the tools that are called ...