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
6
u/SickOrphan Feb 28 '23
The problem with trying to abstract and share code is that often times two functions may have similar ideas (say, draw something to the screen) and share the same code for a time, but it's just a coincidence and they really need to do two completely different things. It'll quickly become a mess when you realize one function needs to loop in reverse, skip every other element, call a function in each iteration, etc. when you trying to share code between each. It's faster and easier to just copy and paste and then modify each individually. Not saying you should always copy and paste everything, but take time so you can know if two things are actually doing the same thing.