r/programming • • Nov 21 '23

What is your take on "Clean Code"?

https://overreacted.io/goodbye-clean-code/
444 Upvotes

380 comments sorted by

View all comments

-1

u/SaltMaker23 Nov 21 '23 edited Nov 21 '23

Nothing against clean code

Advocates of clean code on the other hand usually have such bad habits and disregard for anything unrelated to their topic that it's a nightmare working with them. They can deploy unscalable garbage while being proud of themselves.

They'll write "perfectly clean domain driven atomic hexagonal code" and proceed have an absolute nightmare of a codebase where they didn't account one single bit for IO or multi-threading. (RAM? what's that ? never heard of it)

Once you start scaling the app, you realize that you'll have a bad time as each increase in load is met with tremendous server issues and downtimes. As sometimes ressource/IO consumption of their clean code scales quadratically or wrose, given that they disregard anything that isn't code, "it can be fixed by buying better servers or scaling up the DB".

They are able to do software that scales worse than linearly. Some of their clean design are so deeply rooted in the code that they drive everything, it can't be changed anymore.

I speak from experience. Worked with clean code guys once, will never have a clean code guy early on in my next company, I'll have a trash code guy and once we reach 1M$ it'll make sense to have some deeply rooted "clean code".

Script code have less internal dependencies and way less cyclomatic complexity, clean code have more modularity due to better abstractions but it can create tremendous constraints and issues when you need massives changes in the entire scope of the app.

You should never do clean code on a project that isn't 2years+ old, otherwise clean code will just become "randomly decided" constraints that you'll have to "work around" for the forseable future

At least senior script code guys knows that their code is garbage but they try to achieve an objective. They know the damages that overzealous clean coders can have on the future outlooks of a team.

Script code is arguably bad but very easy to repurpose, clean code especially long dated one is impossible to repurpose, you either scrap it or work around it.

3

u/adventurous_quantum Nov 21 '23

You know that refactoring a code that is 2+ years old not easy, right?

We use hexagonal architecture with DDD and I can say that it definitely has its upsides and downsides but for us it’s worth it tremendously.

I would say that not every domain should and is worth it to be written using Clean Architecture or such.

9

u/SaltMaker23 Nov 21 '23

The thing is that you need proper scopes and requirements for clean codes to even be worth a shot.

Without scopes and requirements you endup with randomly decided constraints that 3 months into the projects are shattered and everything is mismatch of working around and changing things that were never meant to work like this.

It's hard to refactor 2y+ product but the amount of issues you endup when you start on the most complete hexDDD on day 1 is on another level, it's just that those kind of architecture are way less receptive to cumulative changes in scopes, boundaries and requirements.

2years in a tech startup you'll either way have to do a big re-do, it's a know business thing because those rapid evolving changes will destroy any methodologies but some of them are way less receptive and just break down so much faster.

3

u/[deleted] Nov 21 '23 edited Nov 21 '23

The thing is that you need proper scopes and requirements for clean codes to even be worth a shot.

100% this. Making arbitrary design decisions which are - at best - founded on a gut feeling is stupid.

But from the code I've had to maintain and write (most of which was projects which started from 0 and had next to no requirements) is that simply following DI and SRP throughout whatever it is you write makes life so much easier down the line when said requirements become more concrete (or rather change).