News for hackers. Stuff that matters.
Re:The anti-if campaign by amalcon on Monday October 12, 2009 @09:46AM (#876681)
It looks like the complaint is against using IF when type polymorphism would be more appropriate (usually of the form "if(x instanceof a)"). It is almost never a good idea to use IF in those cases, but frankly, this website does not do a good job of explaining the problem.
Re:The anti-if campaign by loup-vaillant on Tuesday October 13, 2009 @03:10AM (#878563)
To replace `if(x instanceof a)`, you don't need type polymorphism (way too heavy). You need algebraic datatypes. With pattern matching (a glorified `switch`), you have the best of both worlds: the compiler make sure you cover all cases (and warn you if you don't), and the code is still local (you don't have to fetch several files to assess its behaviour). If you want to add one case, you still have to modify several snippets, but again, the compiler will warn you if you forget one.

Of course, if their language don't have algebraic datatypes, I strongly suggest they learn one that have it.

Re:The anti-if campaign by chaosprophet on Monday October 12, 2009 @11:15AM (#876864)
Isn't that a minimal use-case??? The presentation of the site seems to suggest that any and all IF statements are to be avoided (though i have to admitted I did'nt get past the landing page).
Re:The anti-if campaign by mdemare on Monday October 12, 2009 @11:34AM (#876915)
And even in those cases, it isn't cut-and-dried. They claim "The advantage is that tomorrow, we can fulfill the request for a new type of bond by simply creating a new class, with the single required logic to calculate the value of that new bond."

Simply? I'd say that creating a new class is a hell of a lot more work than creating a new elseif branch.

Re:The anti-if campaign by j_baker on Monday October 12, 2009 @11:41AM (#876936)
That depends on the context of course. What if that elseif branch needs to be created in two places? Or 20 places?