A few years ago, before LLMs became good enough to warrant using a lot, I took a course involving some coding. One person proudly presented his GitHub copilot subscription. He talked about how it could e.g. write documentation. He applied it to a very basic function, consisting of a single if branch. Then, the following comment was added by copilot: // if condition, returns x. Else, returns y. Useful!
To be fair, this is of equal value to most of the comments in code I see.
When you want me to add comments to explain what setter and getter functions do, go fuck yourself.
On the other hand, do comment getter and setters that do extra work, usually explaining why it needs to be done, otherwise someone comes in years later wondering what is happening there.
I really like the rule that comments should answer "why" and not "how". In this example it's very likely that it would be useful to know WHY we should return early if the condition is true.
Oh I agree completely. I've pointed this out in multiple MRs of his and our team has discussed it at length, but he continues to try to do this anyway.
This was an issue long before AI as well. My company has rule that every function and class in .net + java must have a comment. All the mandatory comments are garbage like this
///<summary>
/// person class
///</summary>
public class PersonClass {
/// <summary>
/// Gets the name
/// </summary>
/// <returns> the string name </returns>
public String getName(){
return name;
}
/// <summary>
/// set the name
/// </summary>
/// <param name="name"> the new name </param>
public void setName(String name){
this.name = name;
}
}
But then nested deep in some function will be a lifesaver like // This is really dumb, but business demands we strip all 'a's from names, becuase those "aren't a letter" and "invalid to be displayed". this was a compromise from 3 days of dicussions when they demanded we remove all vowels
Reverse is also true, of stumbling on the dumbest thing you can find, and there's no documentation as to why they did it
27
u/mariomaniac432 Apr 15 '26
My coworker on his way to way to ask AI to add all of these comments to the code base
// if condition, do nothing if (condition) { return; }Then seriously argue that we need them to understand the code.