I have a class with overloaded constructor (C#) It can be initialized in few ways, and some parameters are optional - so in result - there is a confusing bunch of constructors
new Object(StrA, StrB, ObjA)
new Object(StrA, StgB, ObjB, StrC)
new Object(StrA, StrB, ObjA, StrD)
new Object(StrA, StrB, ObjB, StrC, StrD)
new Object(StrA, StrB, StrE, ObjA)
new Object(StrA, StrB, StrE, ObjB)
new Object(StrA, StrB, StrE, ObjA, StrC)
new Object(StrA, StrB, StrE, ObjB, StrC, StrD)
I see a two ways to improve situation a) create a structure to hold optional parameters
new Config(StrA, StrB, StrD, StrE)
new Object(Config, ObjA)
new Object(Config, ObjB, StrC)
b) set optional parameters as properties
A = new Object(ObjA)
A.StrA = some;
A.StrB = some;
A.StrD = some;
A.StrE = some;
Which is the best way?
And is such code refactoring necessary - the previous code maintainer says that "while intellisense used, complexity of constructor doesn't matter - it always possible to check tips and select the correct one"