When should method overloads be refactored?

Posted by Ben Heley on Programmers See other posts from Programmers or by Ben Heley
Published on 2013-10-29T09:42:41Z Indexed on 2013/10/29 10:17 UTC
Read the original article Hit count: 486

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.

© Programmers or respective owner

Related posts about java

Related posts about c#