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

  • Home
  • SEARCH
  • 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 8316215
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T21:18:39+00:00 2026-06-08T21:18:39+00:00

With best practices in mind, what’s the advisable approach to adding optional parameters to

  • 0

With best practices in mind, what’s the advisable approach to adding optional parameters to a constructor signature? Should you only ever list the core parameters and depend on initialisers for the non optional properties? Seems to me to be the most sensible approach!

  • 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-06-08T21:18:40+00:00Added an answer on June 8, 2026 at 9:18 pm

    In particular with the ability to assign property values with object initializers, multiple overloads for constructors are far less useful than they were. They were mostly useful in the past for setting mutable properties for code compactness.

    Now one can write

    MyClass my = new MyClass() { PropA = 1, PropB = 2 };
    

    Almost as compact as

    MyClass my = new MyClass(1, 2);
    

    while being more expressive.

    However, sometimes the nature of an object dictates that an overload would provide a meaningful contract to the object consumer. For example, providing an overload for a Rectangle class that accepts a length and a width is not unreasonable (I would not ding it on a code review). Personally I would still not provide an overload because object initializer syntax is more expressive, avoiding questions like “was that Rectangle(int length, int width) or Rectangle(int width, int length)?” while reading code (I know, intellisense helps while writing code).

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

Sidebar

Related Questions

What are some best practices to keep in mind when developing a script program
About best practices on designing stored procedures, should a stored procedure updating a record
I am looking for best practices of avoiding constructor injection overuse. For example I
Are there any best practices to keep in mind while designing API's which ensures
What are best practices, tips, and general things to keep in mind for building
I'm looking for best-practices for designing a site that with accessibility in mind. The
What are some best practices to keep in mind when working extensively with SQLite
I would like to know the best practices in your mind to do things
Best practices or tools for installing a SQL Server database I have a SQL
What best practices have you used in unit testing embedded software that are peculiar

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.