Directives

7.1 Document the purpose of the code.

It’s not enough just to add comments to a procedure; you need to write good comments. If you write comments that simply reiterate what the code does, they add almost nothing to the code. In fact, if you’re using good naming techniques to create self-documenting code, these types of comments add absolutely nothing. For instance, look at the comment in the following procedure. It simply reiterates the code itself; the variable names are even used within the comment. This comment documents the mechanics of the code rather than the purpose of the code or the reasoning behind it.

							Private Sub InitiateSale()

   Dim intAge As Integer
   Const c_LegalAge As Integer = 21

   intAge = CInt(txtAge.Text) ...

Get Practical Standards for Microsoft® Visual Basic® .NET, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.