4 ms·
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 ha
by WheelsAtLarge 9y ago
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.
- bobbytherobot 9y agoWhy 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?
- copperx 9y agoStrangely, 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.
- oldandtired 9y agoAgreed. 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.
- tonyedgecombe 9y agoI'm think Reshaper does some of that although I'm not absolutely sure as I don't write comments.
- Frogolocalypse 9y ago? 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.
- sclangdon 9y agoIf 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.
- herbst 9y agoAssuming 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.
- wcummings 9y agoSituations 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.
- enriquto 9y agoBut 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.