I have seen a lot of code like this:
class A
{
public string a;
public string b;
public int c;
public int d;
public A (string a = "something", string b = "something", int c = 123, int d = 456)
{
this.a = a;
this.b = b;
this.c = c;
this.d = d;
}
}
which in my opinion abuses optional parameters. Wouldn't it be better to just make the constructor like this:
public A()
{
this.a = "something";
this.b = "something";
this.c = 123;
this.d = 456;
}
and later on the user can do something like this:
A a = new A() { a = "myString", c = 1000 };
?
Is there any particular reason that makes the first version of the constructor better than the second version?