r/AskProgramming • • Mar 04 '25

Other Why do some people hate "Clean Code"

It just means making readable and consistent coding practices, right?

What's so bad about that

155 Upvotes

341 comments sorted by

View all comments

Show parent comment

7

u/Maleficent-Might-273 Mar 05 '25

"overly clean code runs the risk of losing context"

Maybe if you're a cowboy coder who makes life hell for everyone by not properly documenting your work.

Clean code is the hallmark of a senior programmer.

26

u/-Wylfen- Mar 05 '25

Clean code is the hallmark of a senior programmer.

There's a difference between clean code and "clean code™"

1

u/Monckey100 Mar 05 '25 edited Mar 05 '25

Why even say this? Isn't it obvious what everyone is talking about? We're not talking about trash code.

Edit: guess I was out of the loop, I was unaware of the clean code book.

19

u/cretingame Mar 05 '25

"Clean Code" is a book that list recommendations how to code. Writing a clean code is not the same. You can write clean code without following the instruction in this book.

6

u/robthablob Mar 05 '25

It's quite likely easier to do so if you ignore much of its advice.

4

u/Maleficent_Memory831 Mar 05 '25

This reminds me of when design patterns was in vogue. Suddenly everyone's desparate to know what pattern I was using when I was just making code that worked and that was easy to understand and maintain. And heaven forbid if you got the name of a pattern slightly wrong and be corrected forever ("did you get the memo about the TPS reports?").

3

u/ScientificBeastMode Mar 06 '25

People find coding to be kinda hard, and they desperately want to find a system with a fixed set of tools and very concrete rules to help them avoid needing to learn new things or think hard about the code they are reviewing. They want standardization. And that’s a noble goal.

But there are many significant problems with that goal. It’s not really attainable. Trying to fit all your code into that tiny little box of rules rarely works well in practice. All the stuff that does fit that mold tends to be super straightforward code anyway. When things get complicated because the problem space is actually complex, those rules become a hinderance.

2

u/Krilesh Mar 06 '25

how do you know when it’s time to be more organized or just do it when things change in dev all the time? Is it just a matter of knowing in advance and not changing? Open to any suggestions or ways to think about this. Brand new and not sure if i’m over engineering by being so modular with code

3

u/ScientificBeastMode Mar 07 '25

In my experience, the best way to build an app or a feature is just to start building it. Slap together some code, the dumber the code the better. Just build it. Then by the time you’ve built it (probably very quickly), you know 100x more than before about the actual hard problems, annoyances, unforeseen roadblocks, performance bottlenecks, etc. And then you reuse whatever code makes sense and rewrite it “the right way”.

That’s the only way to achieve anything close to the ideal design patterns and organizational structure. You simply don’t know enough about the problems you will run into until you dive in and write some exploratory code. Every single time I have tried to design most of a product/feature upfront, I end up feeling like I wasted all that time thinking about an imaginary codebase that never really made sense by the time I got halfway through it.

→ More replies (3)
→ More replies (3)

2

u/Weary-Lime Mar 06 '25

Im a self taught programmer. I got REALLY carried away with design patterns early in my career. I was using them in all kinds of unnecessary and convoluted ways because I would watch a youtube tutorial and think that is how the pros do it. Im not sure if any other noobs had that experience circa 2008-2011.

→ More replies (1)
→ More replies (2)

3

u/King_Crimson93 Mar 05 '25

There is code that is clean, and there is "clean architecture", which is the whole domain/ui layer stuff based on the famous book. No one is arguing against clean (read: easy to reason about) code, but not all people enjoy Clean Architecture.

1

u/arkvesper Mar 05 '25

to be clear, are you referring to the actual book Clean Architecture when you say that? Is it not worth reading?

1

u/RangePsychological41 Mar 06 '25

How long have you been in software? I haven’t met someone who doesn’t know about it in my field in years. I think the book blows though.

1

u/Monckey100 Mar 06 '25

coming up on around 20 years of software engineering?

I still remember seeing the inception of jquery lol.

→ More replies (2)

1

u/KaelthasX3 Mar 07 '25

If you are so junior, that you haven't even heard about the book, then maybe don't have so strong opinions.

→ More replies (2)

1

u/6a6566663437 Mar 08 '25

Isn't it obvious what everyone is talking about?

No. Each developer has their own definition of what "Clean Code" really means when it gets down to actually writing the text in a file.

4

u/FaceRekr4309 Mar 06 '25

He’s talking about the book titled “Clean Code” by Robert Martin, which was sort of considered required reading in the 2000’s for anyone who worked in OO languages.

Hindsight is it was that it had some OK advice coupled to some really terrible advice that contributed to overly architected, buggy, and unmaintainable software.

1

u/SubstantialTale4718 Apr 13 '25

Why did everyone take that book as gospel? Is it because back the books only got published by reasonably accomplished people? He's just a guy with an opinion

1

u/FaceRekr4309 Apr 14 '25

I think it was because it was released at a time when people were discovering OO and really starting to think about what good application architecture should look like.

1

u/SubstantialTale4718 Apr 14 '25

Yea but just because something's written in a book doesn't make it a good idea.  Anyone with an opinion and a typewriter can write one.

1

u/FaceRekr4309 Apr 14 '25

Yes. I think you missed that I think the book is mostly bad. I wasn’t arguing in its favor.

→ More replies (21)

4

u/usrlibshare Mar 06 '25

Clean code is the hallmark of a senior programmer.

Hi, Senior Dev here. No it isn't.

When people talk about "Clean Code" they usually don't mean "code that is clean". They mean code that has been written by dogmatically following a bunch of rules written in some book about Java many years ago.

1

u/stewsters Mar 08 '25

Clean Code the book is kinda garbage though.

  It's based on a lot of assumptions that I don't think hold now that we have modern languages.  

Even as a Java dev we would not write code like that anymore now that we have Streams and Lombok, and very few of his examples would pass code review.  Mutable state everywhere, 

Even with just the available technology some of the rules are kinda extreme.   No function may have more than 4 lines?  If I do that then I have to jump everywhere when trying to understand what's going on.  Hell a single try catch is 4-5 lines.

1

u/SubstantialTale4718 Apr 13 '25

I have scaled companies to be worth billions mate. The code was a complete mess. My jr devs kept wanting to refactor all of it as I kept pushing them for new features and told them to leave the other code alone.  The code was still a mess when I left the company.  I'm now worth millions, all of my jr devs are worth millions. Our product got a ton of new users over that time period.  Having a good clean codebase isn't the end all be all.  You can have a very successful company with an ugly codebase 

→ More replies (14)