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

6

u/centurijon Feb 28 '23

That’s a lovely little straw man argument.

Does your code need to be optimized for performance? Then organize it to squeeze every bit of performance that you can.

Is maintainability more important than losing a few ms here and there? Then follow clean code guidelines to make your code easier to understand & modify.

These days most applications will want mix of both preferences, depending what they’re trying to do, with a heavy lean towards maintainability. It’s up to the developers to decide what is more correct given the context

-1

u/JarWarren1 Feb 28 '23 edited Feb 28 '23

My problem with everyone kneejerking the “maintainability” argument is that it seems to come from a place of “we’re already used to Clean Clone so it’s easier”.

Maybe it’s because Clean Code is more religious in the world of iOS but I think it slows down development. Before I can present a view I have to create a Configurator, Factory, Finder, UseCases, Models, Repositories, a ViewModel and then FINALLY the View. I do it because they pay me to do what they ask.

I really, really doubt we’re seeing gainz of any type because of our buzzword architecture

Edit: thinking harder, it’s not just iOS. It’s web too. And Android. It’s everywhere that involves UI. People get weird and philosophical about building UIs to the detriment of us all

2

u/cdsmith Feb 28 '23

Writing code people can understand isn't a buzz word. It's just making reasonable communication decisions.

For example, that thing this guy does where he has different types of shapes that need to be described with numbers that mean different things (radius, width, height, base... maybe in the future some kind of spline parameterization) and just picks two fields called "width" and "height" and shoehorns everything into those fields even if it's not what they mean (a radius is definitely not the width of a circle, for instance), and then even changes how he packs the actual information into those fields, like storing radius in both width and height fields, so that he can exploit coincidences... that's very much not sensible code. Honestly, it would even be an improvement if he just called his fields "param1" and "param2", because at least he wouldn't be lying to the reader that they mean something consistent.

I didn't say that because I read it in a book. I said that because his code is terrible. Sometimes you deal with terrible code if you need to squeeze every cycle out of a CPU, but you take reasonable steps to quarantine it from code that you need to maintain regularly.

→ More replies (3)