Questions tagged [dependency-inversion]
Dependency inversion refers to a specific form of decoupling software modules. The principle is that high level modules and low level modules should depend on abstractions, and abstractions shall not depend on implementation details. Not to be confused with dependency injection which is a special form of dependency inversion.
66
questions
-1
votes
1
answer
141
views
Will I lose confidence of my code working in mocking dependency injected services? [duplicate]
Let's say that I have a class with a service that is going to be injected at runtime:
class Thing {
private magic: IMagic; // Magically injected service
public doStuff(){
// Do a lot ...
1
vote
1
answer
161
views
Can DI without the dependency inversion be replaced by protected properties?
Many people come from frameworks that implement Dependency Injection and IoC containers for everything (in my case Angular 2+), so, this group of people will try to use dependency injection and IoC ...
3
votes
2
answers
380
views
Is it okay to use Dependency injection only because of unit testing?
I have a class that has dependencies that I know are not going to change.
class ConversationFinder
{
public function __construct(
protected Conversation $conversationDbFinder = new ...
-2
votes
2
answers
391
views
How does injecting a concrete class expose implementation? [duplicate]
I've read that you should pass in an interface instead of a concrete implementation so that the consumer doesn't need to know anything about implementation details.
I don't understand how injecting a ...
-2
votes
3
answers
255
views
Should I do dependency inversion on the same layer level
I'm working on an accounting service. I have to generate invoice for a user and upload it to the file storage. So my service would have to use a service from file storage team. File storage service ...
3
votes
0
answers
99
views
How to structure python modules/packages according to dependecy inversion
If I am working on a project, say it has this file structure:
car/
body/
__init__.py
doors.py
bonnet.py
engine/
cyclinderhead/
__init__.py
pistons.py
...
-3
votes
1
answer
161
views
Best way make a complex libraries as a plugin with dependency inversion principle [closed]
For instance, if we have a complex library with many functionalities, how can we make this lib a plugin such that it can be replaced with another lib more easily.
The answer obviously is the ...
3
votes
3
answers
412
views
Is there any redundancy within the scope of SOLID principles?
I have read in an article DIP in the Wild that
"When Robert Martin first discussed the DIP, he equated it a first-class combination of the Open Closed Principle and the Liskov Substitution ...
0
votes
3
answers
183
views
Is it acceptable to inject dependency container in factories?
When trying to design a factory service in a project where i am using a dependency container i sometime find myself in this situation.
I have an interface, in this example ISettingsLoader. ...
0
votes
2
answers
2k
views
Onion architecture: Dependency Inversion Principle within the Service layer
I'm trying to implement a project using the Onion Architecture (aka Hexagonal, aka Ports and Adapters, aka Clean Architecture).
I understand that the user interface uses Service interfaces instead of ...
0
votes
6
answers
932
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
1
answer
94
views
Should you use your own implementation of inversion of control instead of a dependency injection container? [duplicate]
I have a small project that has 6 service classes and a main class. Since they are service classes and does not store any state in it, I declared one static method in each one:
class Main calls 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 ...
0
votes
3
answers
409
views
Orthogonalization vs Dependency Inversion Principle
Is the dependency inversion principle an instance of orthogonalization? Given the class dependency X -> Y a common solution is to introduce interface Z so that the dependencies become X -> Z <...
0
votes
2
answers
197
views
Improving dependency inversion principle
Reading a little bit about Functional core & imperative shell pattern, I am wondering if the DI principle can be improved.
What happen if instead of having an Infrastructure layer depending on ...