in reply to Re: "if" Considered Harmful in OO programming
in thread "if" Considered Harmful in OO programming

I disagree. I don't think duplicating code is good for maintenance at all.

What if you have 3 values instead of 2. Your if would be three levels deep, and have say 5 identical pieces of code. Let's hope you don't forget to change all 5 if a changes is needed. What you suggest is not scaleable at all.

else means all other cases. If you have 2 values in a flat if, else covers the differences of 4 cases. If you have 3 variables in a flat if, else covers the differences of 9 cases. etc. It's not that hard to process, especially compared to what you recommend.