Search code examples
language-agnosticcomments

What should I put in header comments at the top of source files?


I've got lots of source code files written in various languages, but none of them have a standard comment at the top (sometimes even across the same project). Some of them don't have any header comment at all :-)

I've been thinking about creating a standard template that I can use at the top of my source files, and was wondering what fields I should include.

I know I want to include my name and a short description of what the file contains/does. Should I also include the date created? The date last modified? The programmer who last modified the file? What other fields have you found to be useful?

Any tips and comments welcome.

Thanks,
Cameron


Solution

  • Date created, date modified and author who last changed the file should be stored in your source control software.

    I usually put:

    • The main purpose of the file and things within the file.
    • The project/module the file belongs to.
    • The license associated with the file (and a LICENSE file in the project root).
    • Who is responsible for the file (either the team, person, or both)