Re:“Clean Code, Horrible Performance” Discussion
by goto11 on Saturday March 11, 2023 @04:34AM
(#35106853)
So you are saying context doesn't matter, switch is always better?
[ Parent
| on HN ]
Re:“Clean Code, Horrible Performance” Discussion
by pkolaczk on Saturday March 11, 2023 @05:36AM
(#35107121)
If 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.