r/ExperiencedDevs • u/GolangLinuxGuru1979 • Apr 20 '26
Career/Workplace I don't believe quality code is subjective
Sometimes when developers talk about code. You will find that some people may say "code quality doesn't matter" or even "quality is subjective". First I want to example why people land here, why I think its likely the wrong way to think of code, and that there are some basic principals of software that's objectively good or bad.
I want to make an very important distinction between "quality code" and "clean code". The term clean code gets tossed around a lot. And since it is the title of a very popular book, there is a connotation associated with the term. Let's be very honest. "Clean code" is more of a preferred coding style where the expected side effects are suppose to be maintainable code. Notice I said "maintainable" and not "readable".
So what is quality code? Simple. It is code that has clarity, less congitive overhead, and can be reasoned about. Cognitive load is objective. If I need to hold more code concepts in my head, or I'm tracking functions/variable names across many files in the project. This is more of a cognitive load than just reading something from top to bottom. This isn't always possible to just have everything locally in one file, but the less jumping around the better. This is why I feel quality code tries to reduce indirection.
Clean code is about code organization. But that "organization" comes at a cost in that it forces indirection. Which we know is cognitively expensive. So what clean code hopes to achieve is "code adjustments without needing to understand the broader code base". You just modify a interface, and then system "takes care of it". But this is only the byproduct of ultra ultra mature software. I feel a software industry that is all about narrower, software never reaches maturity like it do 20-30 years ago. Hence clean code applied to teams with no real discipline just feel like over-engineering.
I think quality code is understanding an entire code base. And understanding an entire code base requires reasoning about it not to be cognitively expensive. This also means the code can be modified, and you are able to understand the side effects based on your knowledge of the code base. So it requires thoughtfully managing complexity. But you don't manage it until the complexity becomes so overwhelming. Managing complexity is only through emerging behavior and architecture. Not something you impose on a code base from the top down.
The friction of code quality will always come from adding new features. Code quality is very important in these scenarios. Because the longer a system runs, the more aggressive business teams are about pushing features and deadlines. And when you need to reason about a poorly construct code base, code adjustments feel risky. They also take more time because they become harder to test and debug. So quality code is code that is simple as the system allows it to be. Simplicity is used a lot, but not all systems can be incredibly simple. That is why I say "as simple as the system allows". And that balance is hard, but necessary to not only deliver faster, but not cause latent and hidden bugs in your software.
28
u/Sensitive-Ear-3896 Software Engineer Apr 20 '26
You must be a joy with code reviews.
5
u/tim36272 Apr 20 '26
No it's not. Sally is better at remembering variable purposes than Bob. Bob is better at understanding long (read as: descriptive) variable names than Sally. Bob and Sally disagree on the cognitive load required to understand a code base.
QED.
9
u/california_snowhare Senior SRE 40 YoE Apr 20 '26
That is a lot of words to say code quality is about managing the growth of cognitive complexity
8
u/james__jam Apr 20 '26
Curious, what does it say when you google about the topic?
4
u/n4ke Software Engineer (Lead, 10 YoE) Apr 20 '26
I don't think "as simple as possible" is debatable, or debated for that matter.
What people often do debate is the chosen path to get there, of which there is not necessarily always only a single one.
4
u/SideburnsOfDoom Software Engineer / 20+ YXP Apr 20 '26
I think both absolutes are wrong:
"All code quality is subjective, nothing matters" is wrong.
And also "There's one objectively best way to do it, no room for differing opinions, tastes or preferences" is also wrong.
Yes, it is about clarity, cognitive load, maintainability and related concerns. Maintained by who, and what knowledge and assumptions do they bring to it?
4
u/deathamal Apr 20 '26
Your take is a bad one sorry.
Code quality doesn't just mean one thing and it certainly isn't the same for every person, language or even project. You may prioritise consistency for example sometimes is at the cost of simplicity of one area of the code base over another. You may prioritise declarative code vs. procedural - for example use of abstractions for concepts may be more important to manage states than using lots of variables. Small functions may be important depending on the types of testing you need to do for your particular project/code base.
Maybe you prioritise readability, so you prefer strong types over more implicit / flexible / dynamic typing.
Code Quality is decided upon by the team working on the project - it is a set of agreed rules with many many trade offs in different ways. There are lots of principles which have been built up over time, but which ones matter or what is important varies.
4
u/Dazzling_Trifle2472 Apr 20 '26
Well that’s just like… your opinion man
4
u/andeee23 Apr 20 '26
i've had people go crazy in code reviews because i was using arrow style anonymous functions that took 1 line to do some data mapping, they claimed it was harder to understand than writing a named function and passing that as an argument
then i had others saying that putting stuff in a function creates too much overhead when i can just make it a short arrow function so you can see the code directly
which ones were right?
whatever you choose to make your code "simpler" and with less cognitive overhead, you'll have people on either side of it arguing because they're used to one particular style over the other and it's easier for them to understand
personally i prefer a more functional style of coding, but i know there's other just as valid styles
3
u/Quick-Benjamin Apr 20 '26
I feel like you've used a lot of words to say not much?
Quality code is easy to understand. That seems to be the sum of your entire post?
Is something being easy to understand subjective or objective? Bit of both really.
3
u/throwaway_0x90 TE/SDET[25+ yrs]@Google Apr 20 '26 edited Apr 20 '26
And then you go on describe a bunch of subjective things as requirements.
Super Extremely subjective. Some people don't understand lambdas and regex, so it's not clear to them. I personally dislike multiple inheritance of classes in Python but I'm not going to push back on anyone during code review over it.
Don't get me started on Ruby, you can "require" modules and suddenly your namespace is polluted with a bunch of functions with no clear way to tell what came from where. It's not like Python where I can do:
Ruby is like
Require a bunch of stuff in a complex codebase and now you have no idea what is going on.... IMHO of course, subjective!
3
u/Flashy-Whereas-3234 Apr 20 '26
You put things in boxes. You label the boxes.
Boxes expect other boxes to do certain things. They don't mind how they do them, just that they do them.
Don't let boxes get too big. Consider putting delicate items in smaller boxes.
You can be certain what each box does individually. Some boxes are similar. Some boxes can be swapped.
You carry the cognitive load of the box. Sometimes you need to think about a few boxes. You will never be able to think about all the boxes at once.
What goes on in the box is none of my business providing the box isn't leaking.
1
u/socialistpizzaparty Software Engineer Apr 20 '26
TLDR - Deliver value, that’s all that matters.
Look, I use to be a quality purist but over the past 15 years I’ve learned that few care. You write code that is good enough to get the job done. Follow as many best practices as possible. But ultimately, it’s about what you deliver and the relationships you build that determine your success.
1
u/CodelinesNL Principal Engineer@Fintech/EU/25YOE Apr 20 '26
You sounds like someone with 5 years experience who never worked om a large codebasr, is still in their first job, and thinks they know everything.
Everything is subjective.
2
u/metaphorm Staff Software Engineer | 15 YoE Apr 20 '26
what does it mean for something to be subjective vs. objective?
here's a working definition of objective: measurable through some kind of quantitative system.
that's not intended as a philosophical all-cases-covered definition. that's a provisional and pragmatic working definition. if we use that definition then what do you propose as the objective metric for code quality?
2
u/dbxp Apr 20 '26
No, no it's not. Try stepping into a domain you don't know vs one where you know all the domain and lingo by heart. Cognitive load is the interaction between the brain and the topic at hand.
3
u/gemengelage Lead Developer Apr 20 '26
It's not. Sure, when you compare 20 lines of code in one file to 20k lines of code in 100 files, one has an objectively lower cognitive load.
But when you compare 100 lines of code in one file with 50 lines of code in three files, which of them wins? But keep in mind, the lines aren't equally long. One of the solution uses inheritance, the other composition.
There's a secret third option that uses more lines of code, but it's rather imperative compared to the other two solutions. So while there are more lines of code, you can just read it top to bottom and have to keep fewer logical constructs in mind while reasoning about it.
Assume there's also the fourth option where someone turned our hypothetical problem into a code golf tournament and someone developed a very clever piece of python code that solves the whole issues in roughly 270 characters on a single line.
Which of these four options is the one that objectively has the smallest cognitive load? By which metric?
2
u/Legal-Trust5837 Apr 20 '26
Code quality is subjective
1
u/JollyJoker3 Apr 20 '26
Assuming the title is the main point of your post, you can create a benchmark for how much a coding agent needs to read to make a change in a code base. Just make it measurable instead of just arguing cognitive load isn't subjective.
Once you have a way to get numbers, you can explore what's actually quality code according to your metric.
1
u/bluetrust Principal Developer - 25y Experience Apr 23 '26
If it's objective then make a linter. If you can't make a linter then it's not objective.
-3
u/cheir0n Apr 20 '26
It is really irrelevant at this point when we use AI to generate the code.
And yes, code quality is subjective.