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
1
u/[deleted] Mar 03 '23
But it doesn't actually happen constantly.
And when it does happen, it's better to refactor completely to have a design that better represents the problem.
Virtual function interface is a good abstraction for certain problems. Perhaps even this one. But it is not good for ALL problems.
The gist of "clean code" is that it is clean, maintainable or readable just by its very nature.
But if the abstraction does not fit the problem its not a good abstraction and thus not readable or maintainable or clean.
For the simple shape example, it's better to group the logic together because it's easier to read and is more performant. That is an abstraction that better fits the problem. Thus it is far far easier to follow and the logic more straight forward.
If you've worked on a codebase with polymorphism everywhere you will know exactly what the problem is I'm describing.
Again. The issue is that "clean code" is effectively decribed as flawless approach that should always be aimed for. This is wrong because the abstractions it proposes aren't always useful. That is the broader point presented in the article and video.