The Mudcat Café TM
Thread #28443 Message #352922
Posted By: MudGuard
07-Dec-00 - 03:46 AM
Thread Name: BS: Is this comprehensible?
Subject: RE: BS: Is this comprehensible?
Jon, as you might remember I am a professional software programmer. I think the above example should need no comments. I myself use comments mainly to write at a function declaration what the function is supposed to do and what the parameters mean, what is returned and what happens if errors occur. Elsewhere in the code I only write comments if I do something in an unusual way (because it might be more efficient...) But in a teaching environment, I also insist on more comments than really necessary. I offen recommend to write the algorithm first as comments only like in
//for each of the five employees // ask for hours worked // check if more than 20 hours // yes: multiply by 4 // no: multiply by 3.75 // output calculated pay
and then (after once again thinking about it) replace each line of comment by the actual code (or write the actual code before the comment).