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.
137 questions
-1 votes
7 answers
731 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 ...
1 vote
2 answers
222 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
334 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
534 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
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 ...
-3 votes
2 answers
572 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 ...
0 votes
2 answers
195 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 ...
1 vote
1 answer
140 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 ...