4 ms·
So you are saying context doesn't matter, switch is always better?
by goto11 4y ago
So you are saying context doesn't matter, switch is always better?
- pkolaczk 4y agoIf we talk about readability - it is hard to think of a situation when inheritance would be better - it adds an indirection, it hides what's really going on, and at the end of the day the code is also longer and more complex. However it has some other uses, e.g. when you really want to support adding new cases without modifying the code, e.g when doing a library, you need some kind of polymorphism. So basically - it is not that abstractions/indirections are inherently bad, but they come at a cognitive cost. And it depends on the context if this cost is justifiable.