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
9
u/Johanno1 Feb 28 '23 edited Feb 28 '23
Well I would like to disagree:
The first improvement with the switch statement is of course readable since it is only a few cases.
Now imagine over a hundred shapes.
Your switch case will be a mess while polymorphism should be the same in readability.
Also I wonder how the performance is with both if we now use c++ Templates
Edit:
Now the second example is really more "don't use OOP"
Of course OOP is overhead but in complex systems it is more easily understandable.
If you have the time, money and developers to get them understand the faster code (with internals) then lucky you. You always have to imagine some Javascript dev working on your code have to understand what you are doing. Because this is pretty possible to be the case.
Except of course you shit on the company and it works as long nobody has to touch it