Code Commenting Guidelines
Best Practices for Writing Code Comments
By: Dr. Alex Redei
Header Comments
Add a comment at the top of your code: giving the reader an overview of what this code does, who wrote it, and what has changed over time.
//|---------------------------------------------------------------------------|
//| FILE NAME: FileName.cs |
//| |
//| AUTHOR : |
//| |
//| PURPOSE : |
//| |
//| |
//| |
//| NOTES : |
//| |
//| |
//| |
//| REVISIONS: |
//| 5/15/20 - Dr. Redei - Created w/ 4 Unit Tests |
//|---------------------------------------------------------------------------|
Class Comments
Add a comment to the top of the class describing what the class does and any notes:
//|---------------------------------------------------------------------------|
//| CLASS : ClassName |
//| |
//| PURPOSE : |
//| |
//| NOTES : |
//|---------------------------------------------------------------------------|
Function Comments
Invoke the built-in commenting function by placing three slashes at the top of your function, like so: ///
///<summary>
///</summary>
Use Regions
Group code blocks together using C# regions to define a region you use the keyword #region, like so:
#region Public Member Variables
public string sFirstName;
public string sLastName;
#endregion