Code Documentation – Using ‘I’, ‘We’, or Neither

documentation

I find myself writing (hopefully) helpful comments in code (C++) documentation of the type:

The reason we are doing this is...

The reason I use "we" instead of "I" is because I do a lot of academic writing where "we" is often preferred.

So here's the question. Is there a good reason to prefer one over the other in documenting code:

  1. Use "We": The reason we are doing this is…
  2. Use "I": The reason I am doing this is…
  3. Use my name: The reason [my name] did this is…
  4. Passive voice: The reason this was done is…
  5. Neither: Do this because…

I choose #1 because I'm used to writing that way, but documentation is not for the writer, it's for the reader, so I'm wondering if adding the developer name is helpful or if that just adds yet another thing that needs to be changed when maintaining the code.

Best Answer

I'd go with:

#6. Declarative: ...

Rather than say "The reason this was done is because each Foo must have a Bar", just say "Each Foo must have a Bar". Make the comment into an active statement of the reason, rather than a passive one. It's generally a better writing style overall, better fits the nature of code (which does something), and the the reason this was done phrase adds no information whatsoever. It also avoids exactly the problem you're encountering.