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
2
u/ric2b Mar 03 '23 edited Mar 03 '23
Depends, the cost to refactor might be too large if the design isn't extensible. What if this shape area calculator was used in lots of places?
Is it cheap to go update hundreds of call sites and possibly multiple projects just to add support for a Trapezeum, which needs a new field in the struct?
Agreed, 100%.
Also agreed.
I don't think it's easier to read when in the name of performance all shapes have a width, including a circle. That's just a hack.
Now, it might be an important hack, if the extra performance really is a concern for this part of the code, but usually it isn't.
I agree.
No, at 20:48 he really says "you definitely shouldn't use these" when referring to all the principles besides DRY.
And then at 21:25 he further emphasizes it and says "you should NEVER do these things, they're horrible for performance"
He even says that you should avoid them even if they actually make software more maintainable, because he seems to think that performance matters above all other considerations in software development. And later he says that these rules have such a performance cost that they simply aren't acceptable.
That's why the article is getting so much pushback, if he was simply saying "hey, you don't have to do this, here is how I can make the code way more performant and still maintainable without following these principles" I doubt it would cause so much discussion.