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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:04:05+00:00 2026-05-25T10:04:05+00:00

We have a few objects in our domain model with what you would comically

  • 0

We have a few objects in our domain model with what you would comically term offensively large constructors, so large that IntelliSense gives up trying to show it all to you…

Cue a type with 50 or so arguments, mostly value types, a few reference types:

public class MyLegacyType
{
    public MyLegacyType(int a1, int a2, int a3, ... int a50) // etc
    {
    }
}

I’ll say it now, no this type cannot change. The type itself logically represents one entity, which happens to be property-heavy. Callers constructing this type provide the majority of the arguments from multiple sources, though some are defaulted. Perhaps there is a pattern for the sources to be provided to construction instead of the results.

However, what can change is how the type is created. Currently we have sections of code that suffer from:

  • Lack of IntelliSense on the type.
  • Ugly and unreadable code.
  • Merging pains of due to Connascence of Position.

One immediate answer is to utilise optional parameters for default values and named arguments to help with the merging. We do this to some degree on other types, works ok.

However, it feels as though this is halfway to the full refactoring.

The other obvious solution is to reduce constructor parameters with container types that have properties for what used to be constructor arguments. This tidies the constructors nicely, and allows you to embed default values in the containers, but essentially moves the problem onto another type and possibly amounts to the same as optional / named parameter usage.

There is also the concept of Fluent constructors… both on a per property (WithIntA, WithIntB) or container type (WithTheseInts(IntContainer c)) basis. Personally, I like this approach from the calling side, but again on a large type it gets wordy and feels as though I’ve just moved a problem instead of solving one.

My question, if there is one buried in this mess, is: are these viable refactoring tactics for the problem? Please flesh any answer out a bit with some relevant experience, pitfalls, or criticisms. I’m leaning towards the Fluent stuff, because I think it looks cool and is quite readable and merge-friendly.

I feel as though I’m missing the Holy Grail of constructor refactorings – so I’m open to suggestions. Of course, this could also just be an unfortunate and unavoidable side effect of having a type with this many properties in the first place…

  • 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-25T10:04:06+00:00Added an answer on May 25, 2026 at 10:04 am

    Obviously we don’t have much context here, but at 50+ parameters my interpretation is that this class is doing too much, and is too complex. I would start by looking for ways to split chunks out into simpler, more focused types – and then encapsulate instances of each of those concepts into the composite class. So it becomes:

    public MyLegacyType(SomeConcept foo, AnotherConcept bar, ...)
    {
    }
    

    where only the logic necessary for orchestrating between the concepts remains in MyLegacyType (any logic particular to SomeConcept goes there, etc).

    This is different to your “reduce constructor parameters with container types that have properties for what used to be constructor arguments”, since we are fundamentally restructuring the logic – not just just using an object to replace the constructor arguments.

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

Sidebar

Related Questions

int k = 0; k = [myArray indexOfObject:_endNode]; I only have a few objects
My company has decided that we need a generic demo infrastructure for our technology
I have an application using hibernate 3.1 and JPA annotations. It has a few
I am designing a simple web-based application. I am new to this web-based domain.I
I have a new Visual Studio 2008 Database Project (Data Dude). It was generated
My problem is hydrating a Viewmodel from a Linq2Sql object that has been returned
I have four UIViews on a UIScrollView (screen divided into quartiles) On the quartiles,
I am developing a C++ application used to simulate a real world scenario. Based
I'm designing a C# application Presentation ( web site + flex apps ) Business
I am attempting to detect the file type of a library of files on

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.