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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T00:34:41+00:00 2026-05-18T00:34:41+00:00

Here is a question that I have to face a lot when doing the

  • 0

Here is a question that I have to face a lot when doing the design of my little apps. Is there a reason I should prefer

alt text

over

alt text

?

If yes, why? If not, are there any specific circunstances where there is a clear advantage in one approach over the other?

I tend to use the first approach, although I am not too sure why. I guess maybe it is because there may be some concrete implementation of IBonus that might not need a dependency at all, while the second approach is tieing me to something. A stub/mock class, for example.

Thanks!

  • 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-05-18T00:34:42+00:00Added an answer on May 18, 2026 at 12:34 am

    It sounds like you understand the subject quite well. I agree with your argument that there might be an implementation which does not have the dependency and so it’s best not to be tied down. I typically prefer the first approach, like you, for that very same reason and typically encourage that choice.

    In general, I would say that if the dependency is an implementation detail, then it should be passed to the constructor of the concrete implementation. If the parameter is intrinsic to the very definition / nature of the computation, then it is better to pass in the parameter. Another situation where it is a good idea to pass the parameter in the interface is where mutation is concerned; for reentrance, it is better to pass a parameter that you modify over modifying the state of the implementation, so if any side-effects are expected, then I would encourage passing the object to be mutated. That aside, I agree with your view.

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

Sidebar

Related Questions

Spring 3.1 + Tomcat I have a bit of a design question here: There
Here is a question that I have had for some time but never actually
my question is that I have made multimap.Here is the partial code. if(binary_search(final.begin() ,
I've been a long time browser here, but never have had a question that
Basic question here - I have many lines of code that look something like:
I have an other active question HERE regarding some hopeless memory issues that possibly
C# question here.. I have a UTF-8 string that is being interpreted by a
Noob question here! I have an array with hashes that looks like this: arr
I have a quick question here. I know that the cakePHP find('first') function returns
my first question here! I have a problem with a piece of code that

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.