Most “clean code” is actually harder to maintain than messy code. We all love the idea of clean code. Short functions. Perfect naming. Everything looks neat and organized. It feels like the right way to code. But here is the problem. Clean code can become too perfect. Some developers break one simple logic into ten tiny functions just to follow best practices. At first, it looks beautiful. But later, when someone else reads it, they have to jump from file to file just to understand one small feature. What should take 2 minutes now takes 20. That is not maintainable. Messy code, on the other hand, is often direct. Everything is in one place. It may not look pretty, but you can quickly understand what is going on. When there is a bug, you fix it fast because you can see the full picture. Clean code also has another issue. It depends too much on rules. Developers follow patterns without thinking. They focus more on structure than clarity. But code is not written for machines alone. It is written for humans to read later. If your “clean” code makes people confused, then it is not clean. I am not saying messy code is better. Bad code is still bad. But too much cleaning can also break things. There is a point where clean becomes complicated. Good code should be simple to read, easy to follow, and quick to change. Not just neat. So here is the real question. Would you rather have code that looks perfect but is hard to understand, or code that looks simple and maybe a bit rough but is easy to maintain? Most people will disagree with this. Some will strongly agree. But if you have ever struggled to understand “perfect” code, then you already know this is true. #softwaredevelopment #webdevelopment #programming #javascript #fypシ
Indeed. Tools like Sonar force you to break a function into multiple smaller ones just based on the number of lines.
Clean Code is a set of principles and guidelines, not rules. And I think you're mistaking fragmentation for abstraction. Your description of what you're labeling "clean" isn't clean, it's just fractured. Very common mistake. Usually used as an argument to throw the baby out with the bathwater just because most Devs' exposure to design principles comes from those who only think they understand them. Or want to signal how smart they are to dare contradict Uncle Bob. For as many Design Patterns as there are, there are just as many anti-patterns. Mistakes so common they have a name. My advice: learn both, and regard both as bowling lane gutters between which good architecture exists. What you're describing is a classic example of the Gas Factory. Basically, over-engineering. But the alternative of putting all the logic in more singular buckets because it's easier to find sounds suspiciously like the God Class, or Big Ball of Mud. Be careful with that attitude, and advocating for it. That's how tech debt breeds.
I will point out this... When breaking out to multiple methods it should be done because they "Do one thing" - Naming should tell a developer what it does with the only need to look at the code is if the developer needs to know how it does the thing. I will agree that there is a question that needs to be asked on why this code should be abstracted - Going for single line methods many times is a bridge too far. Well architected with a mind towards keep code clean/tidy will make the code easier to test, and change.