Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8228755
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T16:34:07+00:00 2026-06-07T16:34:07+00:00

I have two classes, A & B. B is inheriting from A, I want

  • 0

I have two classes, A & B. B is inheriting from A, I want to inverse the dependency.

Class A { }

Class B : A { }

Class B is inheriting from A. It means B has some dependency from A.

What will be the correct way to inverse the dependency?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T16:34:10+00:00Added an answer on June 7, 2026 at 4:34 pm

    Inheritance is a concept implying tight coupling between classes.

    In order to use Dependency Injection you need to create some “Seams”, as Michael Feathers calls them in Working Effectively with Legacy Code. Here you can find a definition of Seam:

    A seam is a place where you can alter behavior in your program without
    editing in that place.

    When you have a seam, you have a place where behavior can change.

    By this definition, there is no Seam in your example, which is not necessarily a bad thing. The question is now, why do you feel the need to do Dependency Injection in this place?

    If it’s for the sake of example, don’t do Dependency Injection here. There are places where it does not really make sense to apply it: if you have no volatility, why would you do it?

    If you do really feel the need to do something similar in your project though, you probably want to decouple the volatile concepts out of your inheritance hierarchy and create a Seam for these parts: you could have an interface to abstract these concepts, which at this point can be effectively injected into your client class.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two Domain classes (Drives & Computer) class Computer { static hasMany =
I have these two classes MobRec & MobDef and I want to reference an
I have two classes with a parent-child relationship (the Parent class has-a Child class),
I have a base class, Parameter, and two derived classes: Scalar & Vector. In
I have two classes which both derive from the same parent: public class People{
I have two classes A & B, and a listbox. I assign listBox.ItemsSource equal
I have two classes with a parent-child relationship (customer&order directory&file etc) I have typedef
Assume that we have two classes public class EntityA { public EntityB EntityB {
Hi I have two classes, one called Instruction, one called LDI which inherits from
Suppose I have two classes class A { b bInstance; public A ( b

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.