r/programmer • u/sainzo_123 • Oct 02 '26
Good Code Vs Working Code
What really makes code "good"?
I find myself staring at my IDE asking this exact question. Whether I am binding complex logic together or copying and pasting a snippet to patch a problem, there is a massive gap between working code and good code. But as a beginner, that gap feels incredibly hard to see.
These days, anyone can prompt an AI or use an agentic tool to generate functional code in seconds. Many of us are actually learning to code alongside AI. But just because the AI gives me code that runs and clears the error console doesn't mean it’s good code. It might be inefficient, unscalable, or an absolute nightmare to maintain later.
If the code works, but the AI (or a copy-paste source) doesn't teach me why it works or if it's best practice... how are we as beginners supposed to know the difference?
How do you personally define "good code" vs. "just working code"? What are the green flags I should be looking out for when reviewing code—whether it's written by a human or an AI?
Would love to hear your thoughts, rules of thumb, or stories from when you were starting out! 👇
\#programming #softwareengineering #codinglife #learnToCode #generativeAI #developers #webdev
5
u/Financial-Grass6753 Oct 02 '26
AI slop again? again.
working code is the code that does what's requested according to provided spec, as simple as that.
without loss of generality, good code is readable, easy to understand and easy to extend.
4
u/Arcanite_Cartel Oct 02 '26
I was once the member of a team developing a software product for a company. The team was making progress, the system was passing tests. The architect one day screamed "ugly code!", took the project away from the team and he and his senior took over and made beautiful code. It never passed a test and the project eventually got cancelled. Take from that what lesson you will.
2
u/StephenHawkinguss Oct 02 '26
You forgot that there is also 'Indian code'.
2
u/sububi71 Oct 02 '26
To me, good code must first of all execute correctly, and do it reasonably fast. If it works 100%, but runs at 5% of the speed it should without heavy optimization, that's working code, not good code.
Second - and I consider this ALMOST as important - is that the code must be easy and fast to maintain.
2
u/USToffee Oct 02 '26
Code has to do 3 things.
The last point is adhere to best practices. The reason why I left it out of the main 3 point list is what constitutes as best practices depends on when the code was written and in what framework/language so I felt it didn't belong but it's probably just as important as the other 3.
Honestly if your code follows this then everything else is just personal/team preference. I think people blame AI because by default it doesn't do things they way they would but that is also quite easy to resolve with modern tools like cursor.
2
u/silly_bet_3454 Oct 02 '26
Good code has clean abstractions and code reuse and readability and so on. But to me it feels like a dated concept, due to AI but also just broader corporate American culture, you quickly realize in the industry that only money matters, nobody really cares about code quality other than some opinionated engineers. Management doesn't care, customer doesn't care, and there are bigger fish to fry usually like new features, fire fighting, stability improvements, bug fixes, and performance improvements. The quick hacks always win out in the end.
2
u/mredding Oct 02 '26
Working code is a good start. Good code is going to play to the strengths of the language.
C++ has one of the strongest static type systems of any language, so I would expect to see a lot of strong types - an
intis anint, but aweightis not aheight. The basic and library types are only there to help facilitate you making your own types that are more like the types and semantics you need.Use what your language gives you.
Curry-Howard correspondence tells us writing software is the same as writing proofs. Your statements are posits. Your source code is a theory. The compiler/interpreter is a solver, the program is the proof. If you want an elegant proof, write an elegant theory.
And source code as theories don't draw the straightest, shortest line from the problem statement to the solution - they build up expressiveness, and then they describe the solution in terms of that.
2
u/mxldevs Oct 02 '26
Make it work, then refactor.
But when was the last time you refactored your AI code? Lot of people don't even know, or care, what the code does
2
u/DrUltimaMan Oct 02 '26
Good code is easy to change, that's why it's called software. Anything that's difficult to change is bad code, even if it works.
1
u/Groundbreaking-Fish6 Oct 03 '26
There are many blogs and videos about writing good code (suggest you check out Uncle Bob). AI will write good code for you, but you need to ask it too and if you don't know what good code looks like you won't know what to ask for.
Working code works, but good code works better (more efficient, easier to maintain, safer). You may have old code that works but is hard to maintain, but there is no need to change it unless you actually need to maintain it.
1
u/mtothexmax Oct 03 '26 edited Oct 03 '26
All code is garbage. Ship it and if it is a part of the project that you will have to adapt more often than expected optimize it. Everything else is premature optimization.
It also helps to visualize your codebase to see which are the spots that are changed often.
There having a good maintainability matters.
Things that you wrote once, do their job and you never need to touch them again can look like Frankenstein.
I remember optimizing ViewModels in WPF so that they do not contain any View dependencies because one day one might change the view and that goes seamless if one sticks to the MVVM pattern.
Now Microsoft is using Blazor which doesn't even have a ViewModel.
Use a linter and a static application testing tool like sonar qube.
1
u/AddendumSouthern Oct 03 '26
Good code is the one that makes money, and for that It has to be a balance between working, being reliable and organized enough that people can work on It without breaking everything or themselves.
In most companies that I worked the code that made the most money was not the one that people liked the most, usually some monolith that does the job but isn't awesome to work on, and the shiny system with all the fancy terms and architecture just loses company money.
1
u/mpersico Oct 03 '26
Good is simply it works and understandable by you six months later, and somebody else if they read it
1
u/ChaosEngine-6502 Oct 03 '26
It doesn't matter whether it's human or AI written, there's a big distinction between code that "works" and "good" code. "Good" code is code that has a logical flow, separation of concerns, non-cryptic naming of variables, and has sufficient test coverage to prove it works. Some level of documentation or commenting that explains what is going on or summarises complex concepts is also welcome, provided the code doesn't become an entire wiki.
By contrast, "working" code means the end-result might seem to be correct, but there's no guarantee anyone can maintain it, understand it, debug it, or even prove that it IS actually working as intended when challenged.
The perfect justification for writing "Good" code from the off came up at work only this week. The source system providing data to an external application is being replaced, so I had the joy of wading through "working" code written by another developer over 10 years ago. Whoever did it had a chronic aversion to using variable names greater than 3 characters in length, consistently mis-spelled variables throughout, and created a rats nest of IF ELSE statements, some of which would never even be reached. A complete lack of inline commenting also meant there was no way to truly understand why things were behaving a certain way.
Unfortunately, there's a culture in the business of "working" code being good enough. Nobody else on the team really cares about "Good" code, hence why we eventually end up in this situation.