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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:24:20+00:00 2026-05-26T10:24:20+00:00

We use an MVC architecture with a model consisting of a BLL and DAL.

  • 0

We use an MVC architecture with a model consisting of a BLL and DAL.

So we develop “modules” for our system and the particular one I am implementing makes use of alot of the same dependencies. One class in particular has 20 dependencies. Currently the default constructor is creating a default concrete implementation, and we also have a second constructor [that the first one uses] that allows one to inject there own dependencies (i.e. testing.)

20 constructor arguments seems like a pretty nasty code smell.
The other annoying thing is that often when I starting to add common functionality, I need to go add constructor code and fields in every class often repeating the same kinds of code over and over again.

An IoC container seems like a natural solution to this, but the problem is how far do I go? Do I include the DAL dependencies and the BLL dependencies? What about “helper” or “service” dependencies? It seems like at a certain point I am just recreating the “namespace” structure with the ability to reference my classes like static classes at which point I question what I am actually gaining.

I am having trouble thinking through this. Does anyone have an elegant solution or advice?

  • 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-26T10:24:20+00:00Added an answer on May 26, 2026 at 10:24 am

    If you go the IoC route (which I recommend) I would include all your dependencies in the container.

    The benefit is that you never have to worry about creating those dependencies, even if there are a ton of them many layers deep.

    e.g ClassA takes in 4 other classes in it’s constructor, each of those takes in two others in theirs, and each of those takes in at least a DAL reference.

    In that case you just need to reference the IoC in your highest-level layer (the “composition root”), which could be your UI, and say “give me an instance of object A”, then the IoC will automagically instantiate the other 20 instances for the various dependencies needed to construct the object graph.

    Your classes no longer need to worry about how to create their dependencies, if they need something they just stick it in the constructor and the IoC will ensure it gets it.

    I would also comment that 20 dependencies in one class is a definite code smell even if you’re using IoC. It usually indicates that class is doing far too much stuff and violates the Single Responsibility Principle.

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

Sidebar

Related Questions

I am trying to use the backbone architecture in my MVC application. I created
What architecture and patterns can I use to share the most model and logic
I am developing a web application and I am implementing my own MVC architecture.
I need some help with MVC architecture. I use the following architecture for an
Using win forms with an MVC / MVP architecture, I would normally use a
In a MVC architecture the model is used to store data used in the
I use MVC 3 and EF 4.3.1. I have my class created with POCO
I'm trying to use MVC for a new project after having been around the
I am trying for several days to find a reason to use MVC pattern
I am a web and mobile application developer and I prefer to use MVC

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.