Clear questions and runnable code get the best and fastest answer |
|
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
In many ways this is a continuation to the Why my company doesn't use perl :( thread courtesy of ovid we had a while back because commenting code certainly is one of the things often implemented in a coding standard.
I code for myself at the moment, being a poor student, but I still comment my code fairly extensively using a standard of my own devising (see below) for a number of reasons - First and foremost it is a good habit to get into: Much as surgeons, pilots and submariners have specific checklists that they adhere to even when such may not be strictly necessary (Here I make no claims as regards the quality of my code being to such a professional standard!) programmers should also develop such approaches. Get the habit and you'll keep it. If (when?) I end up coding as a job after University this will be one less habit to get into. Secondly in situations where a programmer's code may be read by others it makes sense to give a general guide to your approach to the problem: This makes it easier on other who have to read your code and explains why you have done something in the particular way you have chosen. If other people do this too, you'll find it easier to learn from their code as the approach they have chosen may not be the one you would have taken: This is something you can learn from to improve your own style and breadth of coding experience. Also it will help in code reviews as the person doing the reviewing will have a handle on your method. Finally, sometimes I don't get around to finishing a problem in the time I think I will: My workload can be quite heavy at times (Especially now, as I am studying in a foreign language and have exams every two to three weeks on average) so I might have to put somthing down for a week or two and the thought processes involved in the particular problem won't be simmering in the background as they often are when you're occupied on something. The comments help you to get back on track much more quickly if you've had to lay off something for more than a week or two. Anyway, here's the way I do things:
In many ways you could think of commenting as being like the flow of consciousness as you write your code: It gives ideas as to what (the hell? ;-) you were thinking when you wrote that particular script. Anyway, enjoy. Elgon In reply to Comments as flow of consciousness...
by Elgon
|
|