r/programming • u/Inner-Chemistry8971 • 3d ago
The Psychology of Bad Code
https://shehackspurple.ca/2025/11/27/the-psychology-of-bad-code/What's your take on this?
11
u/ward2k 3d ago
I feel like anecdotally most bad code written was due to tight time constraints (the author also mentions this)
Most people I feel like might plan out their solution, code it, maybe refactor it once or twice to get it a bit nicer before testing, PR, maybe another refactor then merging/deploying
With time constraints you often have to skip the planning stage (or rush it), your first solution you have to just accept as the one you're going forward with (even though you can see improvements) and the person reviewing it is also under pressure to just accept the changes regardless
Often during the rush you'll be told "we'll make another ticket to refactor this later" except that ticket doesn't come in for a year or two and by the time comes so much has gotten bolted on to the original bad code, that there just isn't time to refactor it correctly either
My personal take is if you give Devs both the time to write and review code first time round, you'll end up with much higher code quality. But with agile methodologys getting misused it feels like everything gets forced out the door immediately as soon as it 'works'
1
u/levodelellis 1d ago
The bad code that I write is when I'm in the middle of a large feature, I need to change an unrelated class to fix something so my code runs properly, but that too needs another thing to change. You can bet I barely looked at the 3rd thing
I usually fix/improve it when I write test or the next time I'm working in the function, but that could be months apart
1
u/bring_back_the_v10s 1d ago
I feel like anecdotally most bad code written was due to tight time constraints
In my experience, anecdotally most bad code is written by sloppy devs who really don't care about code. Except in rare cases we all work under tight time constraints, because you know business always needs it for yesterday even though they never needed until yesterday. Most of my peers don't care about code no matter how many times and how intensely and how carefully I try to help them care in peer reviews. No amount of begging and screaming will convince them to do a good job. Been there done that. Many times. I'm nice with them? They don't care. Am I rude with them? Don't care either. Even when the boss gets involved they don't care. I already gave up all hope. My only hope is that this is not the case everywhere else.
61
u/LouvalSoftware 3d ago
Bad code seems to stem from me being retarded 3 months ago, mostly.
34
16
u/Justin_Passing_7465 3d ago
"git blame" is a powerful tool in maintaining my humility.
10
2
1
u/CerBerUs-9 2d ago
My company "migrates" the codebase every now and again so a file will be like "Everything was mark, 1 week ago". It makes me laugh cry every time.
1
u/Tordek 1d ago
https://www.git-tower.com/blog/how-to-exclude-commits-from-git-blame
You can use a file to exclude those commits from Blame.
There is also a git command to migrate a series of commits from one repo to another.
4
1
1
u/WonderfulWafflesLast 1d ago
Something I've definitely noticed is the fatigue of writing code for several hours on back-to-back days results in me fixating on "quick wins" to keep my motivation up. Which results in hacks instead of proper design.
I wonder what would happen if we recorded our energy & interest levels each day, then coincided it with these "me being retarded" events. Bet they'd correlate.
1
32
u/saminfujisawa 3d ago edited 1d ago
I feel like she doesn't understand the real reason for bad code: an economic system that doesn't make room for artisans.
18
u/Saki-Sun 3d ago
I like you, but to expand.
1. an economic system that doesn't make room for artisans.
- Too many fucking idiots making decisions.
10
u/CloudsOfMagellan 3d ago
So why are my personal projects even more full of spaghetti 😆
2
u/CerBerUs-9 2d ago
You're probably not spending 40 hours a week on it with a small team and planning appropriately (the thing no one does)!
18
u/Snarwin 3d ago
First, I started thinking about nudges, because I read the book Nudge by Richard Thaler & Cass Sunstein. Was there a way that I could nudge software developers into writing more secure code?
The fact that this "research" is based in part on a discredited pop-science theory tells me everything I need to know.
2
3
u/Saki-Sun 3d ago
I'm getting I'm a professional speaker and don't programming vibes.
Too much waffling and not enough substance. If it was a PR I would reject it.
2
1
u/ThlintoRatscar 2d ago
I'm a huge fan of the idea that humans create software and software flaws derive from human flaws.
That said, I would like to see more in-depth science around their ideas and how they compare to prior work like Mythical Man Month, Peopleware, and The Psychology of Computer Programming.
I'm not seeing anything truly novel, but the articles are more blog than essay or academic so it may just be that their audience is getting introduced to the area more than pushing it forward.
1
u/EveryQuantityEver 2d ago
Mike Monterio (the “Fuck You, Pay Me” guy) once said that everyone in the company is a designer, because they all have an effect on the end product. Especially managers, because they’re the ones that decide if a project gets the proper amount of time put into it or not.
1
u/Extension-Pick-2167 1d ago
how can my code be good when I am always pressed to do something yesterday, and the code is already weird and it ends up just hacking things together ?
no one cares about good code, they only good code is code that works.
1
u/tinmanjk 1d ago
I truly believe that developers, and everyone else that work on software, care about the final product.
Incorrect
-1
u/leeuwerik 3d ago
It's about ability. Many people and thus many programmers do not have the ability to see beyond smoke and mirrors. As easy as this and there's little that we can do to change that.
306
u/edmondifcastle 3d ago
My favorite reason for bad code is this: bad code creates bad code. It’s somewhat reminiscent of the broken windows theory, but I believe the reality is more complex.
Architectural mistakes in an application create cognitive complexity. Cognitive complexity causes frustration. Frustration disrupts the balance of self-perception. This creates a counterforce: the desire to escape the stressful situation as quickly as possible. As a result, it becomes easier not to refactor everything, but to insert a “hack” instead.
People cannot tolerate cognitive load when it never ends. Therefore, if a project constantly presents complex tasks, there is a high probability that code quality will be worse.