T
7

My friend said my code looked like a 'word salad' and told me to start using comments.

I was just writing functions without any explanation, but after she pointed it out, I started adding simple notes like 'this part checks the user's age' and it made fixing my own mistakes way easier a week later.
3 comments

Log in to join the discussion

Log In
3 Comments
johnflores
johnflores1mo ago
My old computer science teacher made us write comments before the actual code. It felt backwards at first, but now I get it. Trying to explain what you want the function to do forces you to think it through. I still catch myself writing messy blocks without notes and instantly regret it later.
6
the_hugo
the_hugo1mo ago
My last project's comments were basically just "sorry future me" over and over.
5
uma685
uma6851mo ago
My professor had us write the docstring first, then stub the function with just pass statements. It felt silly typing out a whole description for empty code, but it forced us to nail the purpose and inputs. I still do a quick one-line comment before any tricky logic now. What was the hardest part for you when you started?
1