Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

2
votes
4answers
130 views

Is Implementation class exposure fine in Dependency Inversion

Basically we should depend on abstractions instead of concrete classes, that's the Dependency Inversion main principle. interface ITest { void DoSomething(); } class TestImpl : ITest { ...
1
vote
2answers
208 views

How to interpret Dependency Inversion Principle

I am working on trying to understand the SOLID object oriented design principles. I was able to get the "SOL" pretty easily, though "L" required some hand holding because I am bad at definitions. I ...
0
votes
3answers
143 views

Circular dependency in composition root

I have a MDI MyMDIWinForm that needs an instance of IGUIErrorHanlder for error handling, At the same time IGUIErrorHanlder depends on the MDI MyMDIWinForm for having a place from where to launch pop-...
0
votes
0answers
27 views

How to handle sharing of same context in Repositories-Unit of Work when using dependency injection

I have a problem that knocks out me. Background: I am inside the devolpment of a WinForms app that is not layered. Almost all the events are handled in the Form class. I have multiple IRepositories. ...
1
vote
4answers
1k views

How to avoid bidirectional class and module dependencies

To give some context, I'm using python. We have the following package structure: /package_name /request.py # defines class Request /response.py # defines class Response Let also assume ...
4
votes
2answers
383 views

I'm struggling to see how dependency inversion doesn't lead to tighter coupling in lower level modules and less reuseability

I'm refactoring a project I did for my work and I'm trying to apply the SOLID principles to make the architecture cleaner. I've run into an issue with the Dependency Inversion Principle that I can't ...
2
votes
2answers
519 views

Dependency Injection and DI Container

I have implemented clean architecture for my app, and I have a few questions. Typically, pure DI is argued for over a Service Locator pattern, because it is very explicit and more testable. However, ...
0
votes
0answers
45 views

Different kind of settings and Settings manager persistence

I am hesitating what implementation way to choose in the following case. I have a SettingsManager public interface SettingsManagerContract { public void setStringValue(String key, String value); ...
2
votes
1answer
619 views

Is there really such a thing as the onion architecture?

Note: BLL = Business Logic Layer (can also mean your domain) I'm trying to understand the onion architecture. It seems to me that it's actually the same thing as the layered architecture, only with ...
3
votes
1answer
188 views

How Dependency inversion is an extension of OCP?

I am reading about SOLID principles and have just read that Dependency Inversion (DI, to be distinguished here from Dependency injection, which is one way of achieving the inversion) is an extension ...
0
votes
3answers
199 views

Is it generally okay to use concrete classes from OS libraries on an interface?

I do believe that my question is similar to: Is it OK for interfaces to depend on concrete classes? and see/understand what the answer explains about how the dependency-inversion principle should be ...
0
votes
3answers
254 views

Inject type as dependency injection, when new instances are required on each method call - How to avoid?

I have a class public class CertificadoHandler : ICertHandler { Type typeAfirmaValidate; public CertificadoHandler(){ typeAfirmaValidate = typeof(AfirmaValidateCertificate); } ...
6
votes
6answers
1k views

Coding to Interfaces vs Abstract Inheritance

Inheritance vs coding to an interface is something I have wondered with respect to proper architecture design but actually have not run into an problems when using abstract inheritance over coding to ...
1
vote
2answers
115 views

Testable design for a class that can only be instantiated through a static method

I'm attempting to design a class that is to be instantiated through the use of a static method, something like newInstance(param1, param2). The reason behind this is that 2 of the 4 parameters it ...
2
votes
3answers
420 views

How to handle common functionality that is not business logic in clean architecture

The dependency rule in Clean Architecture states that: ... that source code dependencies can only point inwards. I now came across a problem that I cannot figure out myself. Lets assume I have a ...
4
votes
3answers
594 views

Clarification on the Dependency Inversion Principle

I'm reading the book "Agile Software Development, Principles, Patterns, and Practices" by Robert C. Martin. When he talks about the Dependency Inversion Principle he gives the following example of a ...
1
vote
2answers
212 views

Dependency Injection - Return Types

I am confused about Dependency Inversion in general. Lets's say we have 2 layers: Layer0 the low level layer, and Layer1 the high level layer. Layer1 should define the abstract interface, and Layer0 ...
1
vote
1answer
133 views

Dependency Inversion - Software Architecture

Let's say we have an application with a DAL, business layer, and presentation layer, we do dependency Inversion, and we place the database repository interfaces at the business layer. At the data ...
1
vote
1answer
87 views

Should I use dependency inversion in this case?

I have a Document class and a DocumentItem class. A document creates multiple DocumentItems. As my project has evolved, I realized that DocumentItem needed some "deep" logic to properly display, ...
7
votes
2answers
373 views

Why do I need dependency injection and the depencency inversion principal in my case?

I'm a student of best practices, architectural patterns, and design principals. I have been studying dependency injection and inversion of control a lot lately, and have been "drinking the koolade" ...
2
votes
2answers
124 views

Approaches to Dependency Inversion: DIC vs passing through constructor parameters

In previous applications I've worked on, I've had a single factory class which built my object structure, and all dependencies were passed to each class through its constructor parameters. I'm now ...
2
votes
1answer
204 views

Protecting Invariants of Classes

I have a bit of a storm in a teacup at work, and I'm trying to figure out if I'm in the right, in the wrong or maybe a little bit of both. It all started out innocently enough; a developer from ...
0
votes
1answer
132 views

Dependency Injection (DI) and Dependency Inversion Principle (DIP) for built-in functions and external libraries

Question I apologize if this question has already been posted. I tried searching but I couldn't find the answer. I often find myself trying to use DI and DIP where I need to open a file or a socket. ...
3
votes
1answer
455 views

Why support cyclic dependencies at all? Are there valid use cases?

Background Time ago I learnt something about package design, in particular about loose coupling: The Acyclic Dependencies Principle The dependency structure between packages must be a ...
11
votes
1answer
2k 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 ...
2
votes
3answers
714 views

Dependency Inversion Principle - No deriving from concrete classes?

I'm not sure if I am getting this right. In order to observe proper SOLID principles, am I forbidden to inherit from concrete classes? Does that mean that every concrete class that I have more or less ...
5
votes
4answers
932 views

Dependency Inversion Principle and Hollywood analogy

Often DIP is known as the Hollywood principle: "Don't call us, we'll call you.". But doesn't always higher level module calls lower level module, whether there is dependency inversion or not? Then ...
4
votes
1answer
704 views

When should interface be owned by client?

In Agile Software Development: Principles, Patterns, and Practices, Uncle Bob talks about client owning the service interface. My questions are : Should client always own the interface or only ...
5
votes
1answer
161 views

Choosing between Dependency Inversion and Dependency “Delegation” to a third module

Suppose I have MasterPackage containing a Master class, and BlasterPackage containing Blaster class. Since Master needs a Blaster to work, the higher level MasterPackage depends directly on lower-...
12
votes
5answers
2k views

What is the meaning of “inversion” in Dependency Inversion design principle?

I'm reading about design patterns. I know what this principle does. High-level and low-level classes depend on abstractions. But why we say this is inversion?