4 ms·
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
by sclangdon 9y ago
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.
- 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.