All Questions
Tagged with inversion-of-control inversion-of-control
137 questions
-1
votes
7
answers
692
views
If you use Inversion of Control, what alternatives to obfuscated function calls exist?
Consider a class that follows the obfuscated function call anti-pattern. I've also seen these called "stupid classes". The definition of such a class is that it only has one public method ...
0
votes
0
answers
119
views
How to use an external event queue with inversion of control (IoC)
I'm working on an AspNetCore application, with a requirement to raise and handle certain events asynchronously using an external event queue. I'll use AWS services as examples here because that's what ...
1
vote
2
answers
206
views
Why do we separate interface when implementing interface injection variant of DI?
With interface injection (wikpedia) we have a method to set the dependency on the client as part of an interfase.
public interface ServiceSetter {
public void setService(Service service);
}
Why ...
2
votes
2
answers
5k
views
Dependency Injection vs Static Dependencies
I am building a wrapper for a library that requires little complex logic. The whole project is 8 builder classes, 4 classes for doing some pre-processing, and a couple visitor classes. Essentially I ...
2
votes
2
answers
312
views
Abstracting calls to common library methods in C#
I‘m working on making a legacy code base more testable and made good progress with (constructor)-injecting dependencies to classes.
I noticed something in all classes that access the file system: they ...
0
votes
2
answers
221
views
Services should depend on Data or Factories?
I have app which uses IOC container. I have services registered in container, and I can consume either data factory, or particular data object. Which approach is preffereable?
Consuming factory object:...
0
votes
2
answers
514
views
Is it safe to use the same IoC container for your own and third-party services?
I am developing an application with ASP.NET Core with the ability to dynamically add new libraries that implement the necessary functions. They can be included at the start.
I have already written ...
0
votes
1
answer
391
views
Inject configuration files into the injector is it an antipattern?
I'm trying to design a system that inject configuration of each component into each class.
project structure:
|features
--|component-a
component-a.service.js
component-a.config....
0
votes
6
answers
1k
views
If it is a bad practice to use an interface if only one class will implement it, what is the purpose of IoC container?
Okay, first of all I understand the concept of IoC container! It's used to implement automatic dependency injection so you won't have to manually inject dependencies to class. It can automatically ...
-2
votes
1
answer
574
views
Is there a proper way of implementing runtime control of dependencies using DI? Is factory pattern okay? [closed]
I'm currently brushing up and learning about a bunch of techniques to hopefully begin implementing in my own workflow; one of which is IoC (and DI in particular).
I'm hoping someone could clear up my ...
-3
votes
2
answers
566
views
Is inversion of control the opposite of "tell, don't ask" principle?
First, let me explain what I mean by inversion of control and tell, don't ask in this context. I have 4 classes MailController, UserData, Subscription and MailService. MailController is a consumer of ...
4
votes
1
answer
966
views
Dependency Injection: What are advantages of using a framework? [duplicate]
Introduction and Question
I understand what the advantages of dependency injection, e.g. constructor injection or setter injection and that it is one way of doing inversion of control. I also ...
0
votes
2
answers
184
views
Inversion of control
I have been reading about inversion of control and dependency injection and I was wondering the following.
Is there a good way to tell when it is okay to initialise an object inside a method body of a ...
3
votes
3
answers
1k
views
How to decouple chain hierarchy project dependency by dependency injection? (C# .Net Standard)
I'm working on decoupling a Xamarin (.NetStandard) solution. It was using DryIOC container but I didn't see the IOC structure from the dependency, as the projects are still tightly coupled.
Three main ...
1
vote
1
answer
136
views
Inversion of control - no "new" in a low level constructor?
When using IoC in a code base, should one always stick strictly to the pattern without exception?
That means there should be no "new" in any constructor, when the newed object has ...