by Alexandervn · 13y ago · 0 comments
In my projects (usually building websites or webapps) I therefore add a 'readme.md' to the root of the project and document general choices there.
Not only can you explain the why and demonstrate usage in a logical manner, but you get some consistency checks from your documentation for free.
You put them everywhere that might be relevant, along with cross-references to other relevant code/documentation. Humans aren't robots -- redundancy is a good thing, because it helps our feeble minds more quickly reinforce key concepts.
Obviously, redundant comments scattered across the code are even worse: out of sight, out of mind.
Your first job as a professional programmer is making the rest of your team more productive by reducing the communication burden. Your second job is understanding old code. The amount of code you personally write is a distant third priority.
I think treating comments as something that's done in a separate phase is the wrong mindset. Comments should be integral part of code and therefore change whenever the relevant code changes.
// foo library throws an extra two bytes at the front of the
// array, even though that isn't up to spec, so we have to
// strip them out here.