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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:21:36+00:00 2026-05-27T08:21:36+00:00

Lets say you have an object called ServicesProvider which his role is to provide

  • 0

Lets say you have an object called ServicesProvider which his role is to provide services. It will provide services objects such as Mailer, Logger and CacheService.

For those that tend to say it’s breaking the Single Responsibility Principle, how does it break it? Its role is only to provide services, it doesn’t do more than one thing since his responsibility is to provide services objects.

Here is the code:

public class ServicesProvider : IServicesProvider {
   // Properties...
   public ServicesProvider(
       ICacheService cacheService, 
       ILoggerService loggerService, 
       IMailerService mailerService) { ... }
}

Is it recommended to inject this object to any business classes that need services? If not, why? What’s the recommended approach to solve this problem, please provide a complete example?

  • 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-27T08:21:37+00:00Added an answer on May 27, 2026 at 8:21 am

    You’re aggregating all possible dependencies in a single object and then each class instead of requiring only the dependencies needed, requires an object that knows how to get all the dependencies. If you are going this root, you might as well drop the dependency injection part and just use the service locator pattern directly.

    Going this way, you hide the real requirements of your classes, for example you can’t know if a class only requires ICacheService just by looking at its constructor because it receives an IServiceProvider that allows her to request any service at any point of its life cycle.

    As I said, what you’re trying to do is pretty similar to using the service locator pattern so you can research about the pros and cons of using dependency injection vs service locator to satisfy an inversion of control requirement.

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

Sidebar

Related Questions

Lets say I have a single object of type Car which I want to
How to raise combobox_SelectedIndexChanged(object sender, EventArgs e) programmatically? Lets say i have method called
Say I have an object called data which contains a variety of information. Let's
Let's say I have a java.util.Properties object. The Properties object has a method called
Lets say I have an object with two boolean properties: public bool AdvancedMode{ get;
Lets say I have an object that has stringProp1, stringProp2. I wish to store
I have a question regarding events in c#. Lets say I have an object
Lets say I have a Dictionary object: Dictionary myDictionary<int, SomeObject> = new Dictionary<string, SomeObject>();
Lets say I have a Javascript object: var myObj = { property1 : 20,
For example lets say I have a JSON object that contains states and cities.

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.