Code comments
Code tells you how; comments tell you why.
Code comments can save a lot of time and stress for the next person working in the codebase (spoiler: it’s probably future you) by reducing the effort to understand a piece of code, or the intent behind it. Context switching is expensive; a well-placed explanatory comment can reduce or prevent the need, and allow a developer to continue on with their initial task uninterrupted.
Consider including a comment when...
Code is written a certain way for a particular reason
You ran into Something Weird during development
You’ve made a fix for a particular issue or PR
Solution has been copied from elsewhere
Last updated