When should method overloads be refactored?
- by Ben Heley
When should code that looks like:
DoThing(string foo, string bar);
DoThing(string foo, string bar, int baz, bool qux);
...
DoThing(string foo, string bar, int baz, bool qux, string more, string andMore);
Be refactored into something that can be called like so:
var doThing = new DoThing(foo, bar);
doThing.more = value;
doThing.andMore = otherValue;
doThing.Go();
Or should it be refactored into something else entirely?
In the particular case that inspired this question, it's a public interface for an XSLT templating DLL where we've had to add various flags (of various types) that can't be embedded into the string XML input.