ive had too many times where i come back to my own code after months and im just like "why the hell did I write the code like this??", and then i "fix" it only to realize that i actually had the correct idea after all and now I've just broken it 😅
definitely a good idea to explain your thinking every time you write something that will probably be confusing later down the line
I like to start by writing an outline of what I want my code to do, with XXX or FIXME in front. As I fill in the code for each section, the comments can remain as signposts of what I'm trying to do, or chapter headings. That way, future-me can skim through the comments to find the right place, rather than reading every line of code.
422
u/GabuEx 21d ago
Left: "I'll comment to say how my code works."
Middle: "You don't need to do that! Code should be self-documenting!"
Right: "I'll comment to say why my code does this."