What are the different code comment practices? -
What are the different code comment practices? -
reading on code commenting, there seems general back upwards comments not explain code can explain. sources (not many, few still) have looked comments should explaining code on higher level of abstraction.
however, experts in field socialise , work supporting more comments improve not enough, if comments explain reader/coder can decipher code, there different levels of this, , people may decipher code faster others, safe improve comment code meaning not painfully obvious; after all,
"it help you, coder, when don't have read actual code, , can understand function in english, rather seek , decipher code. sometimes, might help writing function out in comments , pseudocode before coding it; help constant reminder of function supposed do."
these 2 quite different schools of thought far comments go. begs question:
what different schools of thought code commenting, , popular (so avoid asking best ones, subjective) sources can read on code commenting practices?
this sharp write-up called the fine fine art of commenting on @ ic#code. it's not perfect (hungarian notation horrible , should not inflicted on developers), still interesting.
the author correctly notes there different things may want utilize comments for, , splits them 3 classes:
documentary comments, illustration copyright information, authorship, , version , changes information. functional comments, various "todo" , "bug" comments signaling out areas of code may require farther attention. explanatory comments, explain code does.the 3rd category interesting 1 beingness discussed here. in opinion, comments should describe why code why does, , not how. example, if codes sorts list, should explain why list has sorted in first place - list beingness sorted (or should be) obvious code.
finally, of import thing comments not compiled , have no effect on behavior of program. may seem obvious. consequence of during maintenance phase of software, bugs in code may fixed, comments remain unchanged, , may document behavior no longer observed. wrong documentation less useful non-existent documentation, of import prepare bugs in comments in actual code.
comments
Comments
Post a Comment