News for hackers. Stuff that matters.
Re:Why can't you guys comment your fucking code? by WheelsAtLarge on Monday July 03, 2017 @10:36PM (#14693105)
I'm a programmer that hates to comment his code so I don't do it. Most programmers feel the same way. Basically the reason we don't do it is because we don't have to. I suspect the only way it will happen is if our code needs it to properly compile.
Re:Why can't you guys comment your fucking code? by copperx on Monday July 03, 2017 @11:04PM (#14693227)
Strangely, I really like to comment my code, although it frustrates me that even the best IDEs have zero support for keeping comments up to date with the code.

Changing, say, a function should prompt the IDE to somehow "tag" the associated comment so that you remember to check its accuracy, at the bare minimum. Other nice-to-haves would be having references to code, e.g., if you talk about variable x in your comment and then rename it, the comment reference should be updated.

You can feel the disdain for code commenting in the industry by looking at the anemic tool support for comments.

Re:Why can't you guys comment your fucking code? by oldandtired on Tuesday July 04, 2017 @02:52AM (#14694039)
Agreed. One of my projects is about updating a specific code editor to manage comments as a "meta-data" of the code itself. Otherwise, maintaining comments becomes a nightmare in the maintenance regime.
Re:Why can't you guys comment your fucking code? by tonyedgecombe on Tuesday July 04, 2017 @04:18AM (#14694369)
I'm think Reshaper does some of that although I'm not absolutely sure as I don't write comments.
Re:Why can't you guys comment your fucking code? by Frogolocalypse on Monday July 03, 2017 @11:26PM (#14693318)
? I comment my code all of the time even more my own projects. I want to know what I was thinking at the time I wrote it. Unless a condition is explicit, I explain what it is doing.
Re:Why can't you guys comment your fucking code? by sclangdon on Tuesday July 04, 2017 @03:39AM (#14694221)
If you think you don't have to comment your code, I don't think your understand the purpose of comments.

If you've been a developer for any length of time, I'm sure you will have encountered a situation where you've read some code, thought to yourself "wow, that's terrible, I'm going to change that". Then, several hours later, realised why it was done the way it was and actually, you can't really improve it after all. That is why we comment; to save the next person who enters the cave (and, if you're the kind of dev who spends several hours trying to understand something and doesn't retrospectively comment what you've found, then I'm afraid we can never be friends).

And please, don't assume the next person has the same knowledge of the system that you do.

Re:Why can't you guys comment your fucking code? by herbst on Tuesday July 04, 2017 @11:35AM (#14696456)
Assuming that is the case and let's also assume there are no related test cases. I will just see where the method is called and try to build test cases around that. Then I can start to deconstruct the method and rebuild it without even understanding it fully. Backed on tests.
Re:Why can't you guys comment your fucking code? by wcummings on Tuesday July 04, 2017 @12:37PM (#14696811)
Situations like that should be few and far between. I write an occasional comment if I'm doing something confusing or unintuitive but the hope is you're not writing a lot of confusing code.
Re:Why can't you guys comment your fucking code? by enriquto on Tuesday July 04, 2017 @05:14AM (#14694608)
But commenting is mostly for yourself! For example, it is very helpful to you comment only your variables (including function arguments).

Declare each variable and argument on separate lines, and add a one-liner comment next to each. If you are afraid that you will fall into comment verbosity hell, you can set up a rule to force yourself to use only single-line comments.

Re:Why can't you guys comment your fucking code? by bobbytherobot on Monday July 03, 2017 @10:57PM (#14693199)
Why don't you have to comment? The first question should be, do you mean you aren't forced to write comments or that your code simply does not need the help of comments?