Some developers add code comments after-the-fact. Some developers don’t add code comments at all (you know who you are). I prefer to add my comments in advance of writing code. This allows me to sketch out my approach to solving a problem quickly. Code comments have the added benefit of helping bring team members up to speed that may be unfamiliar with the project and/or less familiar with the language.
Here’s an example.
// listen for change on fields with the doMonitorChangeState attribute // when they change if the value attribute is different from the initialValue attribute // set isChanged to true // else if the value attribute is the same as the initialValue attribute // set isChanged to false // end if // end listener
Do you have any comments about my approach to comments? Leave a comment about my approach to comments in the comments section below.