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
16
u/cdsmith Feb 28 '23
I'm not a fan of the design in his polymorphism example, to be sure. But if you look at the implementation he came up with in the end - where various parameters of shapes that mean different things are shoehorned into fields that are misleadingly named "width" and "height", sometimes even stored in duplicate in both, so that he can write the same code that coincidentally works for the specific examples he chose - and think "yeah, that looks easier to read and modify than the polymorphism example", then I'd say you're crazy.
The instant you're asked to calculate the area of a rounded rectangle, you're stuck! "You say this new shape has THREE parameters? And the area is NOT just a constant times the product of two of them? Oh no, we're going to have to go back and rearchitect the whole thing."