A collection of Bad Code Smells in a Catalog form for Developers & Researchers. Code Smell is a typical bad code implementation, and learning these concepts immiedietly makes you a better developer!
It’s often a good idea to make the code itself very explicit through verbose function and variable names, rather than writing comments that could lead to inconsistencies between code and comments (by not updating the comments at the same time as the code) (see “Fallacious Comments” from the catalog)
“Some people do a bad job commenting and updating comments, so lets not do comments” is not an approach that works for me.
Most of my code is at the prototype level. I’m concepting something out, usually paired with hardware.
If someone can’t follow what I’m doing, its going to lead to problems. If a change happens to the hardware being controlled, code will not be good enough on its own.
Rather than being accepting of bad commenting practice, make comments (and updating them properly) part of good practice. In my experience, It saves time in the long run and leads to better code at the end.
That’s not what I said. I said that comments can often (but not always) be replaced with good and explicit names.
This can be pushed to some extreme by making functions that only get called at a single place in the code, just for the sake of being able to give a name to the code that’s inside (instead of inlining it and adding a comment that conveys the same informations as the function’s signature)
It’s definetly not for everyone, but for beginners/juniors it gives something objective they can aim for when trying to build good coding habits
I’m not sure how we disagree. At least, I don’t disagree with you. My whole comment was talking about “what” comments. “Why” comments are a very good thing to have where they’re needed
Let’s rephrase my opinion, so that we can (hopefully) agree on something : What I’m arguing against is the “ChatGPT-style” (or “tutorial-style”) comments that I’ve seen all over juniors’ code, even before LLMs got widespread
It’s often a good idea to make the code itself very explicit through verbose function and variable names, rather than writing comments that could lead to inconsistencies between code and comments (by not updating the comments at the same time as the code) (see “Fallacious Comments” from the catalog)
“Some people do a bad job commenting and updating comments, so lets not do comments” is not an approach that works for me.
Most of my code is at the prototype level. I’m concepting something out, usually paired with hardware.
If someone can’t follow what I’m doing, its going to lead to problems. If a change happens to the hardware being controlled, code will not be good enough on its own.
Rather than being accepting of bad commenting practice, make comments (and updating them properly) part of good practice. In my experience, It saves time in the long run and leads to better code at the end.
That’s not what I said. I said that comments can often (but not always) be replaced with good and explicit names.
This can be pushed to some extreme by making functions that only get called at a single place in the code, just for the sake of being able to give a name to the code that’s inside (instead of inlining it and adding a comment that conveys the same informations as the function’s signature)
It’s definetly not for everyone, but for beginners/juniors it gives something objective they can aim for when trying to build good coding habits
I am going to disagree, comments should be an explanation.
The code is what’s being done, a comment should be why its being done.
I’m not sure how we disagree. At least, I don’t disagree with you. My whole comment was talking about “what” comments. “Why” comments are a very good thing to have where they’re needed
Not updating comments with code is what I’m talking about - that’s not a comment problem, thats a programmer problem.
If they aren’t updating the “why”, that programmer is the problem, not comments.
When refactoring, it’s often the “what” that changes, not the “why”
That really depends.
Especially for a function that may see use in a variety of scenarios.
I’m going to be firmly against anyone suggesting against proper comments - which, I’m sorry, but you are by your own statement.
Code will change for many, many, many reasons beyond just refactoring.
Edit: and why it was refactored is important as well.
There are just so many reasons, and yes, I will continue to be against this newer trend of “dont comment, make codes your comments”.
All that is, is a great way to make your code harder to manage later. It doesnt take much effort to explain why you’re doing something.
Let’s rephrase my opinion, so that we can (hopefully) agree on something : What I’m arguing against is the “ChatGPT-style” (or “tutorial-style”) comments that I’ve seen all over juniors’ code, even before LLMs got widespread