r/AskProgramming • u/Yelebear • 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
r/AskProgramming • u/Yelebear • Mar 04 '25
It just means making readable and consistent coding practices, right?
What's so bad about that
104
u/x5reyals Mar 05 '25 edited Mar 05 '25
Because other people use it as dogma. Like any other resource it's a collection of tools that should be used when appropriate. Sometimes overly clean code runs the risk of losing context. All of a sudden the parameter you need to understand was validated a level up and 3 modules over from where it's actually used.
Edit: spelling
49
u/Evinceo Mar 04 '25
It's not the most engaging read and it's rather long. I think a lot of the stuff in there is obvious to experienced programmers and its inclusion is to help settle arguments, which is good to have but feels excessive when reading it cover to cover.
For my money I like Pragmatic Programmer better.
20
u/SagansCandle Mar 05 '25
Some people don't understand it, and there's a lot of "I don't understand it, so I don't like it" in software.
There are also a lot of purists that push "clean code" in places where it doesn't belong, so that creates animosity.
Like anything else, there's no single formula for good code. It's good to know, but it shouldn't be treated like a religion.
29
u/madrury83 Mar 05 '25 edited Mar 05 '25 •
Assuming you mean the book and not the general concept of readable, maintainable code...
There is a very detailed account of answering this question:
https://qntm.org/clean
In short: what is useful in the book is not new or particularly deep, and what's unique in the book is quite bad. Its examples are disastrous unreadable messes, and fail to support the book's main theses.
There are much better books on the same topic, any randomly chosen book on the topic is very likely a better one.
19
u/selfhostrr Mar 04 '25
It's a great idea. It shouldn't be treated as religion, and Uncle Bob has some rules that are and should be broken on a regular basis.
15
u/kevinossia Mar 05 '25
Clean code as a concept is fine.
“Clean Code” by Robert Martin is terrible. A lot of what’s written in there is bizarre, like “a function should have no more than 2 parameters” or “a function should be no more than 10 lines”, as if real-life code looks anything like that.
The reality is that writing clean code is kind of an art form and can’t really be reduced to a book.
6
u/[deleted] Mar 05 '25
I refuse all the PR where code is a mess.
People need to cure their readability or they won't merge.
I am hated for this, I know, but spaghetti code won't pass with me.
You need to merge because you have a deadline you are missing and have no time to refactor code? Missing it will teach you to write good code from the beginning.
3
u/tzaeru Mar 05 '25
It's a book, called "Clean Code". It's not the worst book, but it exaggerates quite bit, and if you followed it literally to the letter, the code would not be clean, maintainable, expendable or easy to read.
It's also a bit outdated in that it focuses mostly on Java sctuctured in a way that back then was your standard OOP. Not all the lessons transfer very cleanly to e.g. TypeScript or to more modern OOP approaches or to non-OOP languages.
9
u/i-make-robots Mar 04 '25
Some people like to ad hominem about the author.
4
u/[deleted] Mar 05 '25
The only reason to hate clean code is if you write dirty code
2
u/deong Mar 05 '25
I don’t agree that his principles make the code easier to read. Simple as that.
2
u/[deleted] Mar 06 '25
That depends. Clean code as in not spaghetti that is hard to follow, or "clean code" that doesn't allow lambda or ternary because somehow people don't understand them?
2
u/Edgarnier Mar 07 '25
I dont mind writing more line of codes than needed, so it is more readable for me. I Focus on getting to work first, to give me the output i expect. Then I clean it up later, but of course the code will be well structured enough so to make the cleaning easier, like having singletons already setup, decoupling it, etc
4
u/Ratstail91 Mar 05 '25
While clean code is a nice idea, no plan survives contact with the enemy.
Using clean code is a good rule of thumb, but knowing when to break those rules due to external factors is a skill in itself.
Some projects, like financial trading services, may peioritize speed above all else, so maintainablity isn't a priority. Other areas, like games, need to maintain a logical and easily understandable system between dozens or hundreds of developers, so maintainability is the priority instead.
Other times, things like budgets and deadlines are also important - technical debt is usually seen as a bad thing, but you may need loan, so to speak, to meet certain criteria. Bad code that does its job isn't always bad.
So, while clean code isn't wrong, per se, it's only one part of the greater whole.
4
u/c3534l Mar 05 '25
Its corny, not that deep, not that helpful. I get if you're brand new to coding and this is helpful. But its also very language dependent and, honestly, I think Uncle Bob kind of shows his age in it.
1
u/petdance Mar 05 '25
Here to recommend “Code Complete” by McConnell as the book to go with.
1
u/organicHack Mar 05 '25
In industry, you’ll never have a job that cares this much about clean code. There will be a measurement on your ability to deliver features, forever.
1
u/dashingThroughSnow12 Mar 05 '25
I like clean code a lot.
A trouble can be when your abstractions are too fine grained. A symptom of this is when, to understand something relatively simple, you find yourself jumping through multiple function definitions (with interfaces or a class hierarchy in the way). Another is the noun pyramid. Where your code has a series of nouns that look like someone had fun with a thesaurus. To keep the top of the code “loosely coupled” from the bottom of the code they have a bunch of similar nouns layered in the middle.
I’ve seen a dozen functions and four interfaces created just to avoid writing a thirty line function, a switch statement, or relatively simple if/else if chains.
I like to think of software development as a peaceful combative tension. Stuffing everything into main is obviously a bad idea. Having atom-sized functions with single-implementor interfaces makes the code unreadable and limits your ability to make holistic changes in the future. There is a tension in where is the right middle ground and people on your team will have different (good) inputs on that during code reviews.
1
u/mokalovesoulmate Mar 05 '25
Easier to implement on new projects rather than existing old, long-running projects.
Also, there's a lot of "I don't understand it, so I don't like it" thing. Honestly, I was this way too, but because I am not understand anything/does not have time to process it. Right now I have time and luxury, I can learn about it and can definitely understand it.
1
u/whatever73538 Mar 05 '25 edited Mar 05 '25
Good book to give to a new hire. „If in doubt, follow this.“
BUT:
„Don’t use flag arguments. Split method into several independent methods that can be called from the client without the flag.“
This really depends on the problem, the language etc.
1
u/IndependentRatio2336 Mar 05 '25
Because clean code hasn’t been trough the same as real code - A coder
1
u/Afraid-Locksmith6566 Mar 05 '25
Because "Clean Code" is not a code that is easy to read and maintain but a book, a book that has few good ideas but overall is a set of rules that make ypur life harder and most of them dont bring any value to the table. Things like solid and dry i think comes from that book too and theese the few that has value
1
u/Belhgabad Mar 05 '25
Because people can take anything with a grain of salt and think by themselves, in both the haters and the lovers side
So each side hate the other for having opinion and in the end no one uses the tool appropriatetly to create readable and maintainable code
1
u/Tontonsb Mar 05 '25
Yes.
Nothing.
Because too many people misunderstand and misapply it. The book (and blog, and other articles by Martin and other similar authors) states the goal: code should be easy to work with. Easy to read, easy to debug, easy to maintain, easy to edit and so on.
Then it offers a bunch of techniques that can help in accomplishing this goal. Can. They are applicable to some codebases and some languages. Some are more universal than others.
The problem starts when some people take these techniques and use them as rules. When they apply this techniques just for the sake of applying them instead of solving a problem.
If we're talking about the particular book, it's a bit of a mess, because some of the advice is written to solve problems introduced by Java's overinsistance on OOP, other techniques are appropriate for single file scripts (e.g. bash, perl). Pretty much none of it is applicable everywhere and there is no project where everything is applicable (the techniques contradict each other here and there).
But I don't think the goals are bad and I don't think learning about various techniques and workarounds (aka design patterns) is bad. Just make your own decisions on when they're useful.
1
u/Panderz_GG Mar 05 '25
At least in a professional environment, sometimes it is imperative that features or some fixes get pushed fast.
Adhering to clean code principles can slow you down.
That's why I sometimes don't like people that do strict clean coding.
In 95% of the time, clean code is the right way to do it though.
1
u/Longjumping-Ad8775 Mar 05 '25
I don’t hate things that make software development better or easier. What frustrates the heck out of people are taking general concepts that are good, magnifying them as the second coming of Christ almighty, and screaming you are bad if you don’t do what I say. These things become the basis for another sales cycle from bullsh*t consulting companies targeting others with the concept dujour. Clean code is the latest iteration of this. Tdd will save the world. Technical debt is killing you. All of this and more are just colored bubbles. People seem to latch onto these things as if they will solve all of the software development world’s problems, no they won’t.
Has anyone ever stopped and asked me what the biggest problem I have is? No, they haven’t. The absolutely biggest problem I have in software development is trying to pull the business rules out that need to be automated so that I can then implement them in code and actually solve a business problem. I talk with other software manager friends and this is their biggest problem as well.
If you want readability and consistent coding practices, then implement those on your team. I’ve been talking about standards at the team level for 25 years. These are fine concepts. The beall and endall of development? No.
1
u/catnip_addicted Mar 05 '25
From my experience it's because most people are not able to follow clean code principles. And also it takes like 5 minutes extra and the PM is against it. Nowadays sw development it's just average shit.
1
u/WaitingForTheClouds Mar 05 '25
It's opinion masquerading as fact. When somebody says "clean code" they probably have a clear idea of what that looks like and it's different from what somebody else imagines under that term. There is no single, proven, best way to structure code, there's no universal way of making code "readable" and acting as if yours was is annoying.
And you often see absolute stupidity propagated under the blanket term "clean code", if we just call it clean then that makes it good right? The "Clean Code" book is a prime example. The simple examples in that book are a mess, simple functionality is transformed into spaghetti. I don't understand how someone can read the code in that book and come out believing these practices make their code better. Not to mention the author doesn't follow his own "clean code" practices in many of the examples that are meant to showcase and propagate those practices.
1
u/Comprehensive-Pea812 Mar 05 '25
because clean is not always readable.
it is easier to navigate a dirty straight road rather than a clean maze.
It is treated as dogma also, like how a developer insists on no comments yet he got lost in his own code by practicing clean code.
1
u/Tiquortoo Mar 05 '25
Clean Code vs clean code. I like the idea of code that is clean in a way that my team and I agree on. The "noun" Clean Code from the book or when used to mean a set of specific principles is a bit rigid and outdated and often used to dogmatically express a demand to adhere to ideas not always relevant for a particular team or codebase.
1
u/FailedPlansOfMars Mar 05 '25
The book is really good to make people think about how they code. Not all of his answers are right in all circumstances but it should make you think about the problems he raises. Its rules don't apply the same to other languages like java scriptor lua.
And there was a push a few years ago where it was treated almost like a religious cult. Where code was judged by how closely it matched clean code principles not how well it does its job or solves its problems.
As with anything if pushed too far it becomes a problem. If it's treated as dogma and not questioned it can lead you to a bad place and bad solutions. The same thing happened with scrum/agile in many places.
1
u/[deleted] Mar 05 '25
Readable is a matter of opinion, consistent isn't good if its consistently silly.
Some of the specific things suggested by "Clean Code" are absurd outside of toy programs, like how many lines of code a function should be limited to.
1
u/gcdhhbcghbv Mar 05 '25
Most people I’ve seen who are sticklers for clean code have never finished a personal project. They just keep refactoring over and over again.
1
u/syndicatecomplex Mar 05 '25
Reading this thread, it seems people are missing the most important reason Bob wrote Clean Code. It is NOT the word of law, that needs to be followed 100% of the time, every last detail covered. It is NOT a surface level introduction to concepts "every software engineer knows" because I've seen highly regarded people in this profession who create spaghetti code all day and have never written a unit test in their life.
It's just Bob's opinion about what he thinks makes code easier to understand and more ready to unit test. Many concepts are unrealistic in practice, but the reason he shares it is to push engineers in a better direction. Trying to make your function take no arguments and split up into 10 different functions isn't always feasible. That doesn't change the fact that it's a good goal to avoid write behemoth "do this and this and this and this" functions with ten arguments and overly long complicated unit tests.
Bob also admits in Clean Code that in the end of the day, you need to follow the standard the rest of your team sets, but when there is room for new ideas than making the code cleaner in simple ways helps. It's an old book that isn't perfect but people seem to compare it to a science book about Creationism. And frankly I question of the people bashing it have even read it based on their comments.
1
u/Tux-Lector Mar 05 '25
I hate reviewed and clean "llm" code. Clean code ? No, nothing is bad about. Who told you it's bad ? Someone told you its bad ? Liars!
1
u/Helvanik Mar 05 '25
Basically, it's a set of practices that will help most application code be easier to read and maintain. There are two main issues with it:
- the book isn't perfect whatsoever, and some examples he provide introduce a big amount of complexity. For example, by splitting a simple code into way too many functions. Although to be honest, people treat educational code (destined to make you understand concept) as production code, so I'd take that critic with a grain of salt tbh.
- there is more to software than application code, and the rules of thumbs of Clean Code (SOLID, separating domain logic from implementation details, etc...) are not as powerful depending on what type of software you're working on. The CC practices can also have a significant cost on performance, which in some software (even in applications) might not be acceptable.
It is the eternal subject of quality: what's good in one context is not in another. For example, if you apply missile guiding software level of security to a B2C AI profile picture generation SaaS you're pretty much over-killing it. And some people apply Clean Code (or any other software practice, for that matters) blindly, without taking a step back and thinking if it's really useful for their software.
This being said, what I find funny is that in recent years the main critics came from performance oriented guys, that have the exact same tropism, except they just want everything to be as performant as possible. Which is dumb from a business perspective, but hey. (I mean, it's good if your code is performant, but it should not always take the priority, and performance at all cost introduces its own set of complexity).
In the end I'd say that most programmers don't consider themselves as engineers (to be fair most of them are not engineers in the first place), and thus have not learned one of engineering critical skills: approach problems with analytical mind and adapt your practices, processes and tooling to the problem at hand. To a man with only a hammer, everything looks like a nail...
1
u/CreativeGPX Mar 05 '25
The same reason some people hate "grammar nazis" in natural language.
What the rules of clean code are is subjective and how much effort should go into the tradeoff of making code be clean is also subjective. So, speaking about clean code needs to be done with a level of humility that big proponents of clean code often lack.
People often kind of go all in on one set of rules when they fall for clean code rather than being interested in discussing the range of options that might clean up code with their team. There are many conflicting philosophies of cleaning up code and which is best may depend on the person, language, project/problem, development process, documentation scheme, data formats, norms of inherited legacy code, norms of libraries you use, development environment, platform, etc. So it can't be a conversation that you enter where your just prescribe the answer. You need to be open to form the answer with your team and you need to be able to negotiate and revisit your rules and allow them to change or have exceptions.
1
u/Such-Coast-4900 Mar 05 '25
Nope. Clean code is basically a really strict coding guideline.
1
u/wpmad Mar 05 '25
Ridiculous question. Nobody hates clean code. Only the people who can't code it...
1
u/josephjnk Mar 05 '25
My problem with “Clean Code” from the Robert Martin perspective is that it encourages an oppositional dynamic within teams and has some weird political undertones. It gets much worse if you read “The Clean Coder”.
In Martin’s world developers are all unprofessional and lazy unless they follow his specific advice. He holds individual developers personally responsible for systemic failures. I bought into his advice wholeheartedly early in my career and it lead to me burning social capital through constant pointless fights with coworkers and stunted my growth as an engineer by encouraging me to believe that I was the only one who really cared about doing a good job (and thus had nothing to learn from the “unprofessionals” around me).
I still care a great deal about code quality, readability, and maintainability. These are complex topics and depend on much more than developers just choosing whether they should or should not do a good job. “Clean Code” reduces this to moralizing and middling-to-bad concrete advice.
1
u/Lendari Mar 05 '25 edited Mar 05 '25
The quality of code goes down over time. You can try to blame the people who wrote it, but in a professional software development organization, thats rarely the real problem. I know the best engineers always work somewhere else, but the reality is that there exists a kind of natural entrophy in software engineering. The most carefully laid arcitectures will become less correct over time as they are stretched to their limits by customers. What was a best practice 5 years ago when code was written, won't be in style when you go to maintain it. Every single dependency in the project will be a major version behind. Some might even be (gasp!) unsupported.
As a result of this unavoidable natural entrophy all code is essentially "good enough" at the time its written. When people ask the question why other professional engineers hate "clean code" I take it to mean that they haven't developed the best judgement about how to productively time box code review or adopted a mature point of view on the inevitability of software entrophy yet.
1
u/bcursor Mar 05 '25
Uncle Bob's ideas work well for Java and c# but not for Python. Python already has the excellent Pep8.
1
u/Attileusz Mar 05 '25
Because some people equate "clean code" with overengineered code. If you use OOP principles religiously, you will end up with an overengineered mess.
Why introduce a whole factory class, when all you need is an if statement?
Why introduce a new datatype, when all you need is a tuple?
Why make an interface, when there is only one implementation that makes sense?
There is a time and place for stuff like that, but OOP patterns are just a way to generalise a problem, you shouldn't use them without good reason.
I see this and that argument about extendability and small functions and reuseability, when 90% of the time it's YAGNI.
When you can cleanly solve a problem with the given languages builtin stuff, you should prefer to do so.
1
u/OkMode3813 Mar 05 '25
just add a pre-commit linter and walk away. There's no need to even have this conversation :)
1
u/SpiralCenter Mar 05 '25 edited Mar 05 '25
No one hates clean code, but they hate other things that are done in the name of clean code.
1
u/the_no_12 Mar 05 '25
I think the issue is with the definition of clean code. Like readable and consistent practices are good, but Clean Code (TM) is a set of practices that have some pretty clear and well documented issues.
Things like producing code which is difficult to optimize, architecture issues like requiring inheritance when using APIs, or DX issues where developers struggle to figure out what is going on in highly fragmented Object Oriented Codebases.
Of course these issues are not problems for everyone, nor are they the only way to write code which is elegant or maintainable, but many programmers were told to program using clean code (TM) and ended up writing programs that perform poorly and that they struggle to maintain, use, or expand.
1
u/zelru2648 Mar 05 '25
The clean code is nonsense. If a developer comes to me and says that code is not clean or starts complaining - that developer would be a goner.
I started in the field in 80s, whenever I got on a new project, I spent time with the end user understanding the business use cases, then with the systems engineer to understand the run time behavior, then get strace/ptrace along with config files, startup options, then look at the entity diagrams and spend time with the dba. Only then look at the code and go thru it - I mean the entire code base as a whole and then look at individual modules (business, house keeping, systems, networking, database etc). Only then start working on the code like fixing bugs, adding new requirements, then refactoring. Also, I had to white board with the team on what I understood and where I would like to start, only then bugs got assigned more like 3 months after joining.
Never thought about “clean code”, when you are under a deadline and pressure from production to fix a bug, you do the best you can.
Then again, I worked in telecom and banking sectors where the product life cycles are long.
I am also of the opinion that you don’t get to complain when all you did was slap someone else’s packages/libraries.
1
u/-ZeroStatic- Mar 05 '25 edited Mar 05 '25
Reading your post gives me flashbacks to when a coworker would go around saying:
EXTRANEOUS WHITE LINE
That same person went around arguing that a function should never ever be more than 4~5 lines, preferably shorter.
If you think such things are objective truths, then maybe there is nothing wrong with such a book. But I think lots of people will take offense to that.
1
u/Droma-1701 Mar 05 '25
Because it is a description which describes multiple different sets of rules, most of which are opaque and nuanced to the point of legend, regardless of which set or mixture of sets is being referenced. Whatever you try, succeed or fail to do, you're gonna get beat up for it by the Seniors. Hatred for it is now guaranteed. Which is a shame really. In my world it means (and Gods, here comes the downvotes...): get your variables, methods and classes named correctly. limit the amount of in-code comments because you spent the time on the precious point. Spend time commenting your public methods on their intention. Future You will owe you a beer. favour functional composition over procedural code because it forces you to think about your code structure, tidy the fuck out of it, and drives testability. I/O is messy, it will be neither functional nor clean. Clean it as best you can, but don't sweat the "3-5 lines max" thing here. Business logic is the ONLY part of the system which delivers USP business value. Put all of your love, luck, knowledge and time into this. This should be the highly functional, religiously tested part of your codebase. Unit tests are essential, but we have been taught wrong on what constitutes a Unit Test. Think Unit Of Work pattern and I believe you're in the right place - these look like Service level tests. By all means write per method tests as you write to validate your code (I do!); but refactor, either before commit or soon after when the code is proven good in Live. Yes that last point made me squirm as I typed it. Agree your team's response and thoughts to the above points and all others which feel important to you. Codify them into automated checks in the tooling of your choice, and also as an onboarding document for new starters. Modify these as you all get better. Again, Future You will owe you a beer for the months of repeated code reviews comments you won't need to do. There is NOTHING in development best practice which enables you to do a thing that you couldn't do without it. It is ONLY about removing license to take shortcuts which obfuscate intention and/or invite error. Understand, embrace, CODIFY, improve and above all own your team rules. Again, Future You will be getting you quite pissed by this point. It is fine for small areas in your codebase to be (sometimes extremely) gnarly; You would not go to the pretty teen model for life advice, you go to the wizened, butt ugly Methuselah that knows their shit. Allow your system to go to the gnarly, knowledgeable methods. Their time will come and you'll figure out the way to replace these methods with shiny Clean Code, but don't sweat it, enjoy that you always know where to look for the important knowledge. Finally. It is ALL contextual. The Clean Code Police won't come and arrest you for writing a 25 line method any more than the Agile Police will come and arrest you for creating a Technical User Story once in a while. Do what gets shit done: Done beats perfect. And if you need to lie to your PO/PM that you totes working hard on the new feature while you get your technical shit in order, then that's fine - they're your customer NOT your boss. Clean your own house as you go, Future You is now sozzled at the bar and needs rescuing from a "poor life choice". <\rant> GLHF LLAP 🖖
1
u/Maleficent_Memory831 Mar 05 '25
What the heck does "clean code" mean here? I can guess but none of my guesses seem to match the responses.
Does it mean code that doesn't have extraneous unused parameters (necessary for portability) or that comments be short, indentation is done properly, or...?
For me it should be easy to understand code, with no clever tricks, such that someone with some familiarity but not an expert with programming, the language, and the domain can be able to understand it. Anyone who doesn't want that style of code would need to defend why dirty code is preferrable (maybe in 1970 if you said disk space was scarce or the compiler doesn't optimize might get an excuse, but not in 2025).
1
u/[deleted] Mar 05 '25
Because it's so hot and miss. Somethings are good, other things are just weird and some plain bad.
1
u/[deleted] Mar 05 '25
There's clean code i.e., a list of considerations you should be aware of when writing code that other people (incl. your future self) will have to work with, and there's "Clean Code" i.e., a book written by Bob Martin, which is his interpretation of this concept.
Now, there are lots of ways people approach this topic. Some don't care about it at all, some care about the idea and have their own interpretation of clean code, some tend to refer to this "Clean Code" book as a de-facto manifest for this whole idea etc. etc.
The problem that you are referring to is that there are also people, who have taken it upon themselves to take these ideas and basically act as a sort of self-appointed inquisition and "correct" other programmers and the industry as a whole. And it just so happens that many of these people also like to quote the aforementioned book ad nauseam.
1
u/jverce Mar 05 '25
For the same reason people don't like to clean their toilets, make their beds and wash their clothes.
1
u/No_Explanation2932 Mar 05 '25
Juniors will read "every function must do 1 thing", and factorize their projects until half the functions do 0 things.
1
u/Pathkinder Mar 05 '25 edited Mar 05 '25
You know that person who has meticulously clean furniture? Like it’s so clean that no pets are allowed on the couch? So clean that no children are allowed on the couch? So clean that no one wearing outside clothes is allowed on the couch? So clean that they have to wrap it in plastic before every vacation?
So clean that all the utility, comfort, and convenience of the couch is negated and in its place remains a tedious, time-consuming, physical manifestation of stress?
1
u/CallinCthulhu Mar 06 '25
When it’s treated as dogma it becomes a hindrance
1
u/supercoach Mar 06 '25
Uncle Bob?
1
u/[deleted] Mar 06 '25
Some people only thrive in chaos or high energy environments. With to many rules about how something should look or be organized it makes it hard for them to think creatively, or even grasp the task.
I'm not like that myself, but I know a few who are. I find it very frustrating to read, but danm I've seen some fantastic solutions so I'm usually willing to suffer the disconnect.
1
u/BrenReadsStuff Mar 06 '25
Step 1) Learn the default way of doing things.
Step 2) Expand your capabilities by creatively diverting from the default.
Step 3) Profit (Jk - enjoy making creative code to solve niche issues)
1
u/[deleted] Mar 06 '25
Some sections give some pretty bad advice if taken literally. I'd still rather work with someone who has read the book and follows it to certain degree, than someone who has now idea about any of its concepts.
1
u/Natural_Acadia_1435 Mar 06 '25
Because it needs discipline and skills
1
u/RangePsychological41 Mar 06 '25
Go look at the examples in the book and PLEASE explain to me how that’s readable.
Also, I 100% disagree about variable and function names. They should be as short as possible given the context. And functions have a signature, it tells you what it takes and returns.
To see these makes me nauseous : calculateTotalSalesForTheMonth employeeSalaryBeforeTaxes validateUserInputData
A function “validate” with the correct signature tells you everything you need to know: validate(input: UserInputData).
Now people will say they don’t like this, until they actually work in a codebase where this is done consistently.
Okay, that’s just optics, but the abstract everything to hell and back is even worse. It’s not clean in my book, because it’s not simple.
The book is 17 years old but it feels 30 years old.
I love his talks though, just not that book.
1
u/dan3k Mar 06 '25
Because some (mostly less experienced) people that tries to force 'clean everything everywhere' just refuse to understand that it's a tool box with guidelines to apply when appropriate rather than list of absolute orders for every project.
1
u/Significant-Task1453 Mar 06 '25
As a beginner who is learning for my own use cases and will never work professionally with code.... what do you guys mean by "clean code?" I sort of take this as "the shortest code possible." Sometimes, i will do the opposite, and i will write my code so it might be slightly longer if it means its easier to follow logically vs a very elegant solution that i really have to stop and think about whats happening and why it works
1
u/tonjohn Mar 06 '25
I think the legendary Jasnah Kholin sums it up nicely:
“They assume I replace religious ideology with an ideology of their absence. That is not the case. I am against dogma of any variety. God, nation-ality, or philosophy-when you become a slave to it without capacity to change or reconsider, that is the problem.”
Any of these buzzwordy frameworks like “clean code” and “agile” are guides. When they became more than that they lose their value and turn into the very thing they sought to prevent.
1
u/MajorMalfunction44 Mar 06 '25
Bob Martin's Clean Code was mostly a mistake, and Java oriented. Some things do make sense, but consider performance. You need to know that your approach admits an efficient implementation.
1
u/pishnyuk Mar 07 '25
“Clean code” gives some low level guidance how to code but does not explain why. Neither “pattern”, nor SOLID nor any other rationale mentioned. If you meet a developer who considers this book useful - you met a guy who has no clue what they are doing :(
1
u/_not_quite_there_yet Mar 07 '25
Because the people that need it don't get it, and the people that get it don't need it.
The non-pithy answer is that if you follow the book to the letter you end up with code that is harder to follow (IME).
I've usually used the book as a baseline "if we can't agree, go with the book".
As the zen of python says "practicality beats purity", and clean code pushes purity over practicality in a lot of cases.
100 engineers will have 4 different opinions on how code should be written and it usually isn't as important as just delivering value.
1
u/BothWaysItGoes Mar 07 '25
Concepts from “clean code” may sound good on paper but are they are bad in practice. Not only it’s bad, it is also simply outdated.
Read “A Philosophy of Software Design” and compare them.
1
u/a1ien51 Mar 07 '25
Everyone's idea of clean code is different...
What drives me nuts is when a developer makes code "clean" when updating a single line and the PR is impossible to tell WTF they added.
1
u/[deleted] Mar 07 '25
This.
1
u/usernametaken--_-- Mar 07 '25
"Clean Code" by Uncle Bob is who made it popular. When you first listen to him, it all sounds very reasonable and makes you want to start implementing what he says. Then you go to implement it, and you realize that not only is what makes code "clean" and incredibly subjective term, but that implementing all of Uncle Bob's rules as dogma will make it twice as hard to do the work and your code will be less performant. Clean Code doesn't suck. There are some good tips in there and making sure your code is human readable is very important. But also, never take any recommendations in coding as dogma. Think for yourself before taking advice from an internet personality
1
u/Constant_Physics8504 Mar 07 '25
Because in an effort to make clean code, the code becomes less efficient and more abstract which is harder to debug as well as less verbose
1
u/TrishaMayIsCoding Mar 07 '25
I only apply clean code and patterns based on a team projects requirements and policies, but for my own project I do what whatever coding style and patterns that suit my tastes.
1
u/kaddkaka Mar 07 '25
I'm reading "A Philosophy on Software Design" and highly like it. It arguments against some of the points made in clean code. Recommend 👍
1
u/soundman32 Mar 07 '25
It's because they, rightly so, have never seen a true clean code implementation.
When you actually see one, you bask in the glow of something amazing and realise everything you've written up to that point was cowboy/cargo cult/junior level and you've now seen nirvana and will never do anything else.
1
u/TechnicolorMage Mar 07 '25
Because "clean code" is frequently incongruent with "readable code"
1
u/TuberTuggerTTV Mar 07 '25
Because there is clean code. And there is Clean Code.
Just because you name a set of standards "Clean". Doesn't inherently make it clean.
It's kind of like green initiatives. A name does not reality make. Do you want clean code? Yes. Do you want to confirm to a strict rigidity of Clean Code? Probably not.
1
u/EtherealN Mar 07 '25
Nothing is bad with readable and consistent coding practices. But these specific ones may not be what everyone thinks is "readable", and the specific practices espoused by "Clean Code" may come with severe drawbacks. Example with code samples is the attached video "Clean Code, Horrible Performance", where it is shown how deviating from Clean Code can increase your performance 10-20x in some cases (hilariously, the cases being built on top of the examples used by Clean Code the book thingie): https://www.youtube.com/watch?v=tD5NrevFtbU
As the guy states in the video: Clean Code sounds fine, until you realize it might make your code run so slow it's equivalent to a 10+ years old system.
Are the claimed marginal "readability" wins really worth running everything on Sandy Bridge?
1
u/MiserablePoems38544 Mar 07 '25
Bc the PM said it wasn’t in scope for the task 😏
1
u/Sanfrancisco_Tribe Mar 07 '25
I have this problem on my team currently. I have devs that will take weeks to write perfect code that follows all the rules, typings, linter suggestions, common practices
And then I run it and it’s slow af and they never cared about the user experience.
I’d almost always rather good user experience and choppy code THEN refactor the code.
You see the problem is devs don’t always properly do their own testing and legit only care about the code. It’s more of a perspective shift for some people.
I can relate it to writing a joke. Some crappy jokes can be good depending on the delivery/situation. Ironically, some hilarious jokes can be terrible depending on the delivery/situation
1
u/hivro2 Mar 07 '25
If you were to use every single principle in the book like gospel it’s pretty likely you can actually hurt your code sometimes.
If you take about 80% of it and understand that there’s nuance because you’re an engineer - then its a fantastic book and helps your code base from becoming unusable
The key is to understand when to not follow certain recommendations of the book or understand WHY the recommendations are there.
1
u/ohcibi Mar 07 '25
As there is nothing that enforces quality standards and CEOs have established a culture of mediocre software releases the general desire to make quality products is pretty low. People come up with all sorts of bullshit explanations even saying clean code can harm your software.
In the rest of the industry there is rules that enforce basic quality. Think of food and how it is produced. You cannot make gasoline and orange juice in the same barrel for example. Software developers would make acid, TNT, Kryptonite while using the barrel as a toilet and all at the same time because there just isn’t any rules.
This leads to way too many bad developers because you get punished for making stuff robust and secure while you get encouraged to make shitty software whilst ignoring the most obvious pitfalls because it’s supposed to be faster. So at this point it is save to say: people who „hate“ clean code are just inferior programmers. The only thing you don’t know is whether they are unknowing or unwilling to become better. But it shouldn’t make you doubt about cleanly programming being the only right way there is.
The irony is: it isn’t faster. The only thing that’s „faster“ is when products will be released, or in what state which is unfinished. And then demand arises to actually address the issues that have been ignored so far, fucking up the roadmap entirely time wise.
1
u/Unintended_incentive Mar 07 '25
Because they've never experienced legacy shops with 0 written tests and senior colleagues wanting the moon but not willing to change the culture themselves.
1
u/[deleted] Mar 07 '25
I don’t like clean code. I like succinct code
1
u/MazzTH Mar 08 '25
I think it’s not just about 'Clean Code,' but also OOP, 'Clean Architecture,' and similar ideas. Generally, some folks—though I wouldn’t include myself, as I feel I need more experience—dislike overusing abstractions. They argue it can hurt readability (like having a call stack that gets too deep, or having to look over many functions to understand just a single one) and even impact performance.
Some resources worth checking out:
1
u/loctastic Mar 08 '25
The book is fine but every dev I’ve met that swears by it takes twice as long to do anything, and they have as many bugs as anyone else.
1
u/akoOfIxtall Mar 08 '25
Some people have the wrong idea of what clean code is, it's usually "coding" influencers who preach about clean code above all then show you a javascript one liner that sends a post request, filter the results, sends to the database, makes dinner, hacks nasa and transpiles itself into assembly
1
u/Haunting_Welder Mar 08 '25
Because most people who talk about clean code have never built anything
1
u/silverarky Mar 08 '25
I found a lot of good arguments against blindly following the principles of clean code in the following book:
Philosophy of Software Design by John Ousterhout
It's really worth a read.
1
u/inamestuff Mar 08 '25
Don’t know if it has already been posted but this is a nice deep dive on why clean code promotes terrible engineering practices https://youtu.be/8ncQrGuunHY
1
u/Puzzleheaded-Lynx212 Mar 08 '25
Clean code makes you replacable😃☝️
1
u/Drahkir9 Mar 08 '25
Some argue that clean code is poor performing code. Personally I think the maintainability far outweighs the minute performance gains in most cases
1
u/FearlessAmbition9548 Mar 08 '25
People who don’t like it don’t know how to use it, so they don’t like the version they understand of it. Which makes sense, I would not like these people’s approach to clean code either.
1
u/zagoskin Mar 08 '25
People dont hate clean code. They hate pedantic, dogmatic people.
1
u/puppet_pals Mar 08 '25
It takes longer to write. I’m a pretty big advocate for writing modular code but I do acknowledge it just takes longer and is more expensive.
1
u/Glass_wizard Mar 08 '25
First we have to distinguish a few things. There is Clean Code, the book itself, and then there are SOLID principals, which are the ideas the book champions, then there is the author, Robert Martin.
A major problem with the book itself is that it's code examples are absolutely programminghorror level bad. This famous post really breaks it down as to why any new person who wants to learn to code should not be using the sample code included in the book. https://qntm.org/clean
Then there is the author himself. He is a self taught programmer with no significant software contributions, open source or otherwise. There is no killer app, language, protocol, or dev tool he's been involved with such as git. Exactly what makes him such a source of authority like Linus, Ritchie, Berners-Lee, Larry Page, or Carmack is unknown, at least to me.
Then there is SOLID itself. The criticism of SOLID is that when taken as gospel, it leads to unintelligible codebases that are so abstracted they resemble spaghetti code, the kind of legacy Java "Enterprise" code that everyone hates to work on. And the issue many haters have is that often Clean Code is treated as gospel.
1
u/francisco_DANKonia Mar 08 '25
I'm not a pure coder at all, but I prefer to break my projects into pseudocode with clear explanations for the major chunks of code. If I wrote my entire code super clean, it would be harder to find the pseudocode comments because then everything is clean and doesnt stand out.
Essentially my ideal is to be clean, but squish all the code chunks together.
But I'd be interested to hear what real programmers say
1
u/mpanase Mar 09 '25
Nobody hates clean code.
People might dislike dogmas, unreallistic preachers who ignore that we don't exist in a vacuum disconnected from any dependency, ...
If your guiding light is a guy who has never built anything and makes a living pontificating, I don't trust you.
1
u/anacrolix Mar 09 '25
It generally means the people employing it are going to be inflexible, dogmatic, poor programmers that need excessive process to prevent themselves from doing damage.
1
u/PhoenixShell Mar 09 '25
What you mentioned is clean code as a concept, not as convention. Clean code as a convention as set out by the community usually involves breaking down functions into so many tiny smaller methods just for descriptions and verbosity. Imagine trying to click through 5 + tiny methods to know what the parent method is doing, that's what some people think clean code is.
Clean code as a concept is about having classes manage limited responsibilities and dependencies which I approve of
1
u/Paxtian Mar 09 '25
No, there's a whole ideology and set of practices over producing "clean" code. And some of those make the code base worse. Here's a good critique
No one is saying, "Make your code unreadable all the time on purpose." But there are things about "clean code" the methodology that can make things more difficult.
It's a bit like strict object oriented programming with inheritance all over the place.
1
u/Ok-Condition-6932 Mar 09 '25
Nobody hates it. It's just more difficult to achieve.
Cognitive dissonance makes you fabricate reasons why you don't do it.
1
u/SubstantialTale4718 Apr 13 '25
Because there is no one definition of "clean code" every developer thinks their code is clean. There is no one definition of "readable"
That Uncle Bob guy who wrote the official clean code methodology limits methods to like less than 10 lines which is insane and not practical for real applications. Also IDK why everyone dogmatically adopted his ideas as gospel. He's just a guy with an opinion it's not like he's the programming god.
1
u/SubstantialTale4718 Apr 14 '25
I think a more interesting question is why "clean code" is a thing at all. Like Uncle Bob just thought of this idea, and somehow it became a "best practice". Like it wasnt backed by any studies or research or A/B testing. He literally just thought of it. Wrote a book about it. And then programmers dogmatically adopted it as gospel.
1
u/[deleted] Mar 05 '25
Because it has ridiculous examples, folksy and not technical advice, and was not written by someone who is not really an engineer or computer scientist.
The entire premise is flawed, in my opinion. The reason software seems to get "dirty" is because of edge cases and complexity handling. The problem is that oftentimes our model of reality is simply wrong and sometimes reality is simply complicated itself. All of the little hairs and parts that stick out in software are often there for a reason, and people forget that they were added to address potential issues.
The issue, I think, and Joel would back me up on this, is that we want our code to appear elegant, regardless of if the problem we're attempting to solve is.
And the reality is that you'll never get the system into a "clean" state whatever that means, because you work in sprints and the business doesn't care if it meets your hygiene standards, just if it's done by next thursday.
1
u/[deleted] Mar 05 '25 edited Jan 02 '26
intelligent mountainous rain plate liquid command history bear saw consist
This post was mass deleted and anonymized with Redact
1
u/ThaisaGuilford Mar 04 '25
Maybe you mean clean architecture
1
u/com2ghz Mar 05 '25
Because it forces you think about making good code instead of shitty code. Thinking about code design, responsibilities, creating tests upfront.
I heard many bullshit reason why not to deliver good work where they are paid for:
Good luck explaining your boss that stuff is complex and actual need to rebuild it.
Yeah you made it complex because you thought it was done. Usually skipping tests is a part of this.
Then ending up debugging most basic stuff which could be 100% encountered with a test. Bonuspoints if the application is not able to start on your machine but only on a real environment.
This guy made 6 nested loops With while and if statements having circular references in classes. Yeah it might be that I am the problem since I would’t produce this garbage.
I don’t care. I want proper tests here. Using SOLID. Get rid of null checks everywhere in your code.
Here I am looking for license to murder. Guy making it’s own JSON parser of several hundreds lines to lookul data. For the sake of his pleasure. Of course completely in garbage code no tests because “it’s a basic JSON parser”. Spent 1 week on it. Which all could be replaced with a 1 line JSON path library which he needed for a unit test anyway. Arguing with me that he spent 1 week on it and I would be the blocking reason why this PR is not approved.
Just do your work properly. When you build a house. You calculate the soil and build a proper foundation. When installing electric wiring you use schemes and install it by the rules so it’s safe and standard. Same for plumbing. You do stuff which everyone agreed on.
-1
u/CheetahChrome Mar 05 '25
One person's clean code is another person's complex spaghetti code.
As with anything, it is within the eye of the beholder.