B
30

Just realized my old commenting style was terrible for beginners

I used to write massive code comments explaining every single line, like 4 paragraphs for a 10-line loop. Last week I joined a group project and saw someone just use short descriptive variable names and almost no comments. I finally got it - clean code speaks for itself, comments are for the WHY not the WHAT. Has anyone else had that moment where you realized you were overcomplicating something simple?
3 comments

Log in to join the discussion

Log In
3 Comments
hart.sage
hart.sage7d ago
Three hours of my life I'll never get back from the time I wrote a 5 page README for a basic calculator app. The worst part is I still somehow made it confusing.
8
hart.sage
hart.sage5d ago
Take the "why" approach and stick to it. Comments should explain the reasoning behind a weird workaround or why you chose one weird approach over another. If someone can read your code and understand what it does from the names alone, you're golden. The only time I add more is when the code is doing something that looks wrong but isn't, like handling a browser bug or a weird edge case. Everything else is just noise that gets stale fast.
8
noaht15
noaht157d ago
Wrote a haiku for a for loop once. Still cringe thinking about it.
7