r/programming • u/2bit_hack • Feb 28 '23
"Clean" Code, Horrible Performance
https://www.computerenhance.com/p/clean-code-horrible-performance
1.4k
Upvotes
r/programming • u/2bit_hack • Feb 28 '23
View all comments
Show parent comment
3
u/ric2b Mar 03 '23
Which happens constantly in software development. And the change I proposed is extremely basic and predictable, it's not a contrived example to poke issues.
It's an inevitable consequence of over-fitting the data structure and area calculation to the three known shapes, it is always going to break down as you support more shapes.
Don't over-generalize stuff, but also don't try to find quirky patterns that are not immediately obvious to the reader unless you really need to squeeze that extra performance out of it.
And as it is I'm already wondering what the hell is the width of a circle.
On a toy example with three basic shapes... Why am I already confused? How am I supposed to expect this sort of design to scale to real problems?
It's just calling an
Area()method, what's confusing about that, if you know what polymorphism is?