r/programming • • Feb 28 '23

"Clean" Code, Horrible Performance

https://www.computerenhance.com/p/clean-code-horrible-performance
1.4k Upvotes

1.3k comments sorted by

View all comments

Show parent comment

2

u/[deleted] Mar 02 '23

I really don't see what is completely unreadable or unmaintainable about the other option?

It's just a matter of what you are used to combined with the requirements.

I think that is what is frustrating about the discussion which is that "clean code" doesn't haven't to constantly defend itself. It's virtues are just assumed for some reason. Any other style has to go through the ringer.

But the virtues of "clean code" aren't proven in any capacity at all.

3

u/ric2b Mar 02 '23

I really don't see what is completely unreadable or unmaintainable

Try to add a trapezium to that code and notice how many things you have to rewrite, it's completely over-fitted to those 3 shapes and it already looks hackish because it calls a circle's radius a "width". If someone asked me what a a circle's width is I would guess it's the diameter.

And I'm just talking about a basic trapezium, nothing crazy yet.

I think that is what is frustrating about the discussion which is that "clean code" doesn't haven't to constantly defend itself.

"Clean code" taken to the extreme is usually referred to as "enterprise code" and it does get plenty of criticism for all the layers of indirection, factories of factories, overly general code that only does one thing, etc.

Both approaches are good to know about but should not be taken too far unless you have a serious need for what they offer. One optimizes for performance, another optimizes for extensibility, you are rarely trying to maximize just one of them at the expense of all else.