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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T18:21:51+00:00 2026-05-16T18:21:51+00:00

We have many long-running processes that each require dozens of steps. Each step is

  • 0

We have many long-running processes that each require dozens of steps. Each step is relatively complex in its own right, so we broke those steps into their own classes. We are using DI/IoC (StructureMap) to help us make the whole thing testable. This has been working great, but we find ourselves with oodles of dependencies in our controlling classes.

For example, on of our larger routines processes client 401k file uploads. This has almost 70 discrete steps. Each logical group of steps is in its own class, 14 in all. Each of those are pretty small and manageable, but the class that organizes the whole affair has a ton of dependencies (i.e. we have a bunch of God classes):

    public Client401kProcessor (IValidator uploadValidator, 
        IGeneralLedgerExporter glExporter, 
        IDataMapper dataMapper,
        IFinanceRepository financeRep,
        //...9 more
        IClientFileAuditor auditor)
    {
        _uploadValidator = uploadValidator;
        //... etc
    }

This particular class only has a couple public functions, making it very easy to use:

    public void ProcessClientFile(Guid savedFileId)
    {
        var clientUpload = _financeRep.FetchClientFile(savedFileId);
        _uploadValidator.Validate(clientUpload);
        _dataMapper.MapToStagedArea(clientUpload);
        _dataMapper.FlagAsStaged(clientUpload.Id);
        //...
        _auditor.RecordChanges(client.Id);
    }

I feel like we must be missing something. It’s pretty straightforward to test, understand, and write the above code … but .NET folks have been telling us that we have too many dependencies. How would we reduce these dependencies and still make the code easy to test/maintain?

  • 1 1 Answer
  • 1 View
  • 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-16T18:21:52+00:00Added an answer on May 16, 2026 at 6:21 pm

    As Aren says in his comments, you can introduce an aggregating service – a middle man that takes care of the coordination for a set of dependencies. The first question you have to ask yourself before doing this is what the responsibility of the class with all those dependencies is. Is it really having a single responsibility?

    Read Jeffrey Palermos blog post on the “constructor over injection” code smell and follow the discussions and the follow up posts it caused. Mark Seeman posted a couple of follow ups, including “Refactoring to Aggregate Services”, which is a good read in your case.

    In your specific case, the ProcessClientFile method could perhaps be extracted into a ClientFileProcessor class, or a couple of classes if the file processing consists of several logical steps with discreet responsibilities.

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

Sidebar

Related Questions

Suppose we have many user processes running on Linux. Each process has many threads
I have a form that has many long-methods. My quest is: What is the
I have a really long integration test that simulates a sequential process involving many
I have some long-running operations that number in the hundreds. At the moment they
I have a long running io process that I would like to be able
I have a long running job that updates 1000's of entity groups. I want
I have a form that is going to be executing a failry long running
I have a basic C# console application that executes a fairly long running process
I have a running system that process short and long running operations with a
I have a long running process in my MVC application(C#). Its building data for

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.