10
Just realized most new coders skip writing comments because they think it slows them down
Spent 3 hours debugging my own code from last month because I was too lazy to leave a single note, and now I tell everyone in my bootcamp cohort to write at least one comment per function, has anyone else tripped over their own old code like this?
2 comments
Log in to join the discussion
Log In2 Comments
rowan_butler9315d ago
Comments are for people who forget what they wrote. Real coders write clean code that explains itself with good variable and function names. If you need a comment to understand what your code does, the code is probably too complicated. Pulled apart some messy spaghetti code from a guy who wrote paragraphs of comments, and every comment was either wrong or describing something obvious like "this adds two numbers." Writing comments just gives you an excuse to write bad code. Plus comments get outdated fast when someone changes the code but forgets to update the note.
2
ericfox15d ago
Gotta push back a little on this one. Clean code is great, but comments can save your butt when you're dealing with weird business logic or a hacky workaround you had to use. I've seen plenty of "self-documenting" code that still leaves you scratching your head about why something was done a certain way. Comments that explain the "why" not the "what" have saved me hours of digging through Git history.
5