Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Some people certainly do! My favorite examples of how not to write comments are these code snippets from the API guide I was given at a previous job. The other 60 pages of API documentation are just like this- all what and no why.

The problem isn't that these comments are harmful (they're not), but that inserting these comments made the coder feel like they'd done their job of commenting their code well, when in actuality the comments provide no insight to why certain things are called or instantiated, or what certain values represent; critical knowledge one needs to extend the code beyond the specific example cases the API guide presented.

----

  ‘ A for loop iterates through each row of DataGridView
  For Each row In DirectCast(Me.DataGridView1.Rows, IEnumerable)
----

  Dim frmTakeBackTask As New TakeBackTask
  ‘ Public oTaskData of TaskBackTask gets populated from the local object oTaskData
  frmTakeBackTask.oTaskData = oTaskData
----

  ‘ A For loop is initiated to iterate through each child node contained 
  ‘ in the XML document
  For Each record In xmlDoc.ChildNodes.ItemOf(0).ChildNodes
      ‘ A nested For loop is initiated to iterate through each column
      For Each column In record.ChildNodes


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: