Re:Fear and Loathing in Programming La La Land (2012)
by sitharus on Monday July 15, 2013 @06:48PM
(#6049025)
Yeah, been through that before. We just standardised on using overloads for external APIs, it's cleaner externally.
The real issue is if you have DoSomething(string what, autoRetry=true) and you change to DoSomething(string what, autoRetry=false) - DLLs compiled against the old version will call with true even if the authors wanted the default behaviour.
Re:Fear and Loathing in Programming La La Land (2012)
by sukuriant on Monday July 15, 2013 @06:53PM
(#6049049)
That makes sense. As I said in my other thread, I locally deal with that problem by passing null instead of a primitive (though admittedly, I would probably use a primitive in cases of bool).
That said, in this circumstance my method sounds more like a hack and yours the cleaner, correct route.
Personally, I don't really see that as much of a problem. Having run into that issue before, I think the compiler catches it as as an error because its an ambiguous method signature. Instead, you have to pass something like: "DoSomething("foo", (string)null)" which, in that case, defeats the purpose of the optional parameter altogether.