2 ms·
I agree with you, especially in instances where that decision logic is unrelated to the data that is actually being used. In your example you'd have to pass "th
by viceroyalbean 5y ago
I agree with you, especially in instances where that decision logic is unrelated to the data that is actually being used. In your example you'd have to pass "thing" everywhere just for that if-statement, but it might not be used for anything else.
That said, I think "simple" if/else or switches are much more common than the complex cases that fit polymorphism, so it seems a bit off to have it as a general rule to prefer polymorphism.