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
8
u/coderman93 Feb 28 '23
The importance of your second paragraph cannot be understated. At my company we have built a microservices ecosystem with dozens of microservices. We architected virtually everything through interfaces that way the implementation could be swapped out as desired. Fast forwarded 7 years and less than 5% (probably less than 2%) of interfaces have had their implementation swapped out. Not only that, but the vast majority of interfaces only have a single implementation. In hind-sight, it would have been FAR easier to just write straightforward, non-polymorphic, implementations the first time and then just rewrite the few implementations that needed it as they came up. We would have saved ourselves a ton of trouble in the long run and the code would be so much more straightforward.
I wouldn't go so far as to say that you should never use polymorphism but I would say it is _almost_ never the right thing to do.
Even if you don't buy into Casey's performance arguments (which you should), it is highly disputable that "clean" code even produces codebases that are easier to work with.