What would be the main attributes of good code?
For further actions, you may consider blocking this person and/or reporting abuse
What would be the main attributes of good code?
For further actions, you may consider blocking this person and/or reporting abuse
dev.to staff -
Michael La Posta -
Elman Huseynov -
Michael Tharrington -
Latest comments (58)
Well, if your answer is as undocumented as your code, I hope I never have to read any of your code...
Linux code follows Linus Torvalds principles, and they are notoriously harsh:
infoworld.com/article/3000564/linu...
So, no, it's not just about accomplishing the task.
Once I heard..."It is a good code if the cost to change the code is minimum" or something like that.
-Well executed
-Clean Code
-Documentation
(optional hehehe)
-Open source
My opinion is that high quality code has the following characteristics:
I think those three makings translate to ease of introducing change, quick developer onboarding, rapid prototyping and pattern-first programming, greatly increasing productivity.
Very nice question @julia !
But it does matter. If you ever had to do any sort of code maintenance or expanding of existing code this is obvious. Code that is "clean"/"good" is easier to work with. "Does the code work?" is very important, but it doesn't even begin to be good code.
These books you mention, I would love to hear your arguments against their actual point instead of dismissing them by mentioning Linux or any other project, since that's not really the point.
Cheap and easy to maintain!
Uncle Bob says:
That is good advice for a beginner!
Well, there is a lot of books, articles and talks for that matter, but all of them lead to two things: low coupling and tests.
If it's feature, it must be connected to codebase through interfaces and properly tested (mocks, benchmarks for critical parts etc).
If it's refactoring, tests must remain untouched.
Looks pretty simple, but it's not.
My personal definition is very subjective: A code is of high quality if
Ideally it should have all these properties:
That's not necessarily true in all cases.
You write code as language for a computer. When you speak to another person, whether it's functional or an expression, you can say it in multiple ways -- all accomplishing the same task, in bad, good, great, and best ways. "Accomplishes the task" is ambiguous, as is the task's definition. For example, a task to display an RSS feed on a page is different for a junior dev vs an intermediate, or even another junior dev. It's very well different for different types of people, roles, cultures, etc.
Code quality measurement is like checking someone's health. If your life purpose was defined with 100% accuracy and our biotech was 100% accurate could one accurately determine a person's health exactly. Because we're far from that point, we make estimations based on multiple dimensions like weight, height, sugar levels, etc; similarly, we have test coverage, penetration/smoke testing, analytics, user group sessions, etc.
Professionally I do not even have an experience to use for reference, but as a student I would say this:
-> Quick run
-> Quick reading
-> easy to understand
Quality code is stable and easily maintained.
I’ll chime in with some characteristics I try to impart to my code:
Some comments may only be visible to logged-in visitors. Sign in to view all comments.