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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T03:22:29+00:00 2026-05-11T03:22:29+00:00

Occasionally I come across methods with an uncomfortable number of parameters. More often than

  • 0

Occasionally I come across methods with an uncomfortable number of parameters. More often than not, they seem to be constructors. It seems like there ought to be a better way, but I can’t see what it is.

return new Shniz(foo, bar, baz, quux, fred, wilma, barney, dino, donkey) 

I’ve thought of using structs to represent the list of parameters, but that just seems to shift the problem from one place to another, and create another type in the process.

ShnizArgs args = new ShnizArgs(foo, bar, baz, quux, fred, wilma, barney, dino, donkey) return new Shniz(args); 

So that doesn’t seem like an improvement. So what is the best approach?

  • 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. 2026-05-11T03:22:30+00:00Added an answer on May 11, 2026 at 3:22 am

    The best way would be to find ways to group the arguments together. This assumes, and really only works if, you would end up with multiple ‘groupings’ of arguments.

    For instance, if you are passing the specification for a rectangle, you can pass x, y, width, and height or you could just pass a rectangle object that contains x, y, width, and height.

    Look for things like this when refactoring to clean it up somewhat. If the arguments really can’t be combined, start looking at whether you have a violation of the Single Responsibility Principle.

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

Sidebar

Related Questions

Occasionally I'll come across comments about inheritance going out of style in enterprise application
I am a c++ programmer and occasionally I'll come across some code that is
Occasionally, I've come across a webpage that tries to pop open a new window
fairly new Android developer here. I've come across a strange problem that I'm not
I occasionally come across pages where some Javascript is included via a PHP file:
I come across this pattern occasionally and I haven't found a terribly satisfactory way
I've come across this several times, ctrl-c randomly does not copy. I think it's
Occasionally, I have come across programming techniques that involve creating application frameworks or websites
Hopefully this will not come across as a silly or pedantic question, but I'm
We've come across a rather annoying bug in IIS7.5 where it occasionally removes the

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.