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 7868391
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T00:58:59+00:00 2026-06-03T00:58:59+00:00

Lately I find myself not caring too much defining dependencies for a class and

  • 0

Lately I find myself not caring too much defining dependencies for a class and passing them in the constructor, but I just always pass the DI container and keep it in a private attribute. This way my class won’t have very well-defined dependencies, I get everything from the container when I need it.

Somehow I have bad feelings about this solution though (apart from the overhead caused by accessing the container), but I can’t really think of too much disadvantages. Maybe having loose definition of dependencies can decrease portability of a class, or I get surprises when refactoring…?

What do you think about this?

  • 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-03T00:59:00+00:00Added an answer on June 3, 2026 at 12:59 am

    Absolutely wrong. Don’t put the DI container in the objects; they need not know or care that they’re being injected. This doesn’t square with “don’t call us; we’ll call you.”

    It’s the other way ’round: the overall app knows about the DI engine, but then it gets the beans it needs from it.

    I suppose you might argue that annotations change the relationship some, because now the beans do know something about the fact that they’re wired together. But when configuration was externalized into XML, it was true that beans were ignorant of DI.

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

Sidebar

Related Questions

I've not done much coding for Windows lately, and I find myself sitting at
I've been trying to study up on PHP lately, and I find myself getting
I've been using python too much lately and I forget if there's a way
I've been doing it like this lately and find it so much better than
I find myself doing quite a bit of testing lately using FIX messages as
I have learned a lot about EJB3.1 lately, but apparently not enough. Here's my
Lately I'm interested in the topic of genetic algorithms, but I couldn't find any
I have been looking at LLVM lately, and I find it to be quite
Hey, as of lately, I've been trying to find good ways to smoothen out
Lately, I've often found myself wanting to run some command on the output of

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.