daru.se

3-June-2023: Code comments sucks

I recently was assigned to extend some code a colleague has written. I have the pleasure of working with very good developers and in this specific case even Rust. Short story, the code is good.

So I was getting trough the code wrapping my head around it mostly reading code. But also paying attention to code comments as they should make it even simpler.
Thing is that at least one comment was outdated and/or just wrong. Which led me astray for a while.

But then I read or watched something online that was bashing code comments. So I decided to try out an experiment.

I was doing my research in a separate git branch I had created. So I just went ahead and deleted pretty much all the comments I found!

Then I continued the process of learning how the code worked. And it was fucking awesome. As I said, the code was good. So comments was not necessary. I read code, understood code and was not sidetracked or distracted of some comment that may or may not be accurate.

I think this is easier with other peoples code for some reason. When I later looked at my own code which has a bunch of comments I felt very reluctant to delete them. Maybe I should and see if I get the same result?
Could be that I just write worse code and need my comments? Ouch!