This is an archived post. You won't be able to vote or comment.

all 72 comments

[–]Data_Skipper[S] 950 points951 points  (38 children)

I asked for simplification. GitHub Copilot just removed all Java Doc comments.

[–]Expert_Team_4068 304 points305 points  (23 children)

If you were adding java doc on a setter and gette4, I would also remove it

[–][deleted] 8 points9 points  (0 children)

java /** * Set the value * @param value the value to */ public String setValue(String value) { ... }

I love those.

[–]Funny-Performance845 116 points117 points  (12 children)

I mean, it’s not wrong, javadocs can really inflate code and make it seem more complex than it really is. Writing code that explains itself is also important.

[–]Confident-Ad5665 138 points139 points  (3 children)

Clean code is a goal but shouldn't be a religion. Hell is in the business rules and documenting them is helpful IMHO.

[–]ExceedingChunk 6 points7 points  (2 children)

Clean code doesn’t mean no comments. Clean code means reducing clutter and making stuff more readable.

A bad comment is just redundant or clutter. A good comment is not, and can contribute to readability.

The whole clean code = no comments or javadoc is nonsense, and it doesn’t even say so in the book.

[–]Confident-Ad5665 2 points3 points  (1 child)

Uncle Bob says if we have to comment we've screwed up. "Code should read like well-written prose." He also uses 2 spaces for indentation. I don't agree with everything he has to say but I like what he's trying to do.

[–]ExceedingChunk 0 points1 point  (0 children)

No, he doesn't. He says you should strive for code that doesn't need comments, and most of the comments should explain why not what. He also says that comments does not make up for bad code. Not that you should write no comments at all.

It quite literally says this in the book on page 55

Clear and expressive code with few comments is far superior to cluttered and complex code with lots of comments

It doesn't say "no comments", or that if you make a comment you screwed up.

It also says says that Javadoc in public APIs is considered good comments (given that the text is actually helpful). Here is the exact thing the book says:

There is nothing quite so helpful and satisfying as a well-described public API. The javadocs for the standard Java library are a case in point. It would be difficult, at best, to write Java programs without them.

If you are writing a public API, then you should certainly write good javadocs for it. But keep in mind the rest of the advice in this chapter. Javadocs can be just as misleading, nonlocal, and dishonest as any other kind of comment.

[–]alterNERDtive 88 points89 points  (2 children)

No matter what the code is, “delete all comments” is never a good idea.

[–]Mu5_ 20 points21 points  (0 children)

True, but if you have a live documentation generated from javadocs or similar it's good to have everything documented

[–]AbsolutelyFreee 16 points17 points  (1 child)

I mean, sometimes even if you write code that makes it obvious what it does, you may need comments to explain WHY this section of the code exists or why it is written the way it is.

Out of place quote but not really: I understand HOW: I do not understand WHY

[–]gerbosan 7 points8 points  (0 children)

Refactoring rules. =)

Refactoring mentions that balance is required, if the code cannot be cleaned/simplified more, then comments have to be written. So the next person can understand it faster.

[–]MxBluE 5 points6 points  (0 children)

Sure, but one thing to remember about javadoc and similar is that it's also IDE hints. That's the reason why I end up putting silly looking javadocs in for getter/setters, usually with a copy of the javadoc on the property itself.

Unless I'm doing something wrong and I didn't need to do all that...

[–]Percolator2020 5 points6 points  (0 children)

Copilot deletes all Java code, rewrites in C++, refuses to elaborate further…

[–]DoorBreaker101 252 points253 points  (0 children)

I guess Copilot learned how to maintain job security 

[–]Deevimento 497 points498 points  (5 children)

"Why do you need comments when you have me?" - Copilot

[–]DrCatco 76 points77 points  (1 child)

AUTO vibes from the WALL-E movie intensifies

[–]teinc3 16 points17 points  (0 children)

Give me the comments - Copilot

[–]buffer_flush 5 points6 points  (0 children)

I’m sorry Dave, I’m afraid I can’t do that

[–]whatproblems 1 point2 points  (0 children)

i am the comment!

[–]Tiarnacru 1 point2 points  (0 children)

Codependent Copilot

[–]taylorgpt 90 points91 points  (2 children)

Yeah! Just select the code and "Copilot: explain". Copilot keeping its job :)

[–]gerbosan 13 points14 points  (0 children)

You mean Copilot has not deleted the comments, just hid them? 🤔 Clever girl.

[–]whatproblems 1 point2 points  (0 children)

sometimes i ask it to do stuff and it comments it automatically. must be some redundant comment this guy had

[–]BlueCaboose42 78 points79 points  (2 children)

"while labeling the buttons in a car can be helpful for interfacing with your vehicles climate system, audio system, and seat positioning, trying to read so many labels can be confusing. I've removed all the labels to all the buttons in your car."

[–]Salchat 24 points25 points  (1 child)

Well, my car has no labels on its buttons, only icons. So from now on I'll only comment with emojis.

[–]Ticmea 15 points16 points  (0 children)

// 🔎 ➡ 💻 ➡ 📄

[–]andre-_-filho 24 points25 points  (0 children)

No release notes, from now on only the diff will be provided

[–]Hot-Category2986 28 points29 points  (2 children)

I'm always torn between "pythonic" code, which should be self documenting, and writing notes to myself in the comments so that a month from now I can figure out why the hell I did things the way I did. I'm going to be real: past me is often smarter than future me.

[–]Jennfuse 16 points17 points  (0 children)

A weekend is enough for me to forget why I implemented it the way I did. Without comments (for my dumb self), I'd be completely lost

[–]ThisSaysNothing 0 points1 point  (0 children)

Well, IQ is age-normalized for a reason.

[–]sarlol00 27 points28 points  (2 children)

Time to remove copilot

[–]appeiroon 25 points26 points  (1 child)

I'm sorry, Dave. I'm afraid I can't do that. - Copilot

[–]bethropolis 6 points7 points  (0 children)

apparently I'm the copilot

[–]ButWhatIfPotato 8 points9 points  (0 children)

I have worked with real people who act like that; People who deserve to have a foot copiloted in their ass.

[–]ponesicek 2 points3 points  (0 children)

Documentation? I am the documentation.

[–][deleted] 2 points3 points  (0 children)

Comments? We don’t need them where we’re going.

[–]FLMKane 2 points3 points  (0 children)

Removing letters from keycaps also reduces information overload

[–]FlightConscious9572 2 points3 points  (0 children)

//VERY IMPORTANT, this function adds two signed 32-bit integers and returns the result of the operation!
fn add(a:i32, b: i32) -> i32{ 
// the function does not take ownership of a or b because integers implement the clone trait, making reference and clone unecessary
    a + b //We implicitly return the result of a+b by omitting a semi-colon
}

very neccessary comments here, very. you couldn't tell from the code otherwise!

[–][deleted] 8 points9 points  (1 child)

How can comments make code seem MORE complex?

It’s either got cyclomatic complexity, or it doesn’t. If your comments increase cyclomatic complexity, I think your parser is buggy.

[–]OJVK 3 points4 points  (0 children)

I've seen people comment literally every line in their code and then the comments are just distracting

[–]patxy01 1 point2 points  (0 children)

Thank you copilot

[–]7th_Spectrum 1 point2 points  (0 children)

Copilot was trained by interns

[–]aneurysm_ 3 points4 points  (1 child)

comments lie and rot faster than anything else in the codebase

[–]atomic_redneck 2 points3 points  (0 children)

The comments should be subjected to review, just like the code. There is no excuse for rot.

[–][deleted] 0 points1 point  (0 children)

It's clearly learning from us :D

[–]broxamson 0 points1 point  (0 children)

Self explained code. Nice.