| 個人檔案沦为相片部落格清單 | 說明 |
|
4月3日 资料 学英文My Comments on Comments in ProgramsTraditionally there are two schools of thought with comments.
The 2nd school of thought says that as all code should be self documenting, you should always use sensible variable and function names. Whether you comment or not I couldn't agree more about the use of sensible names if the code has to be reused or maintained. Over the years I have written plenty of code using single or double letter variable names. But that was back when interpreters walked the earth (1980s) and long variable names were fractionally slower to parse than shorter ones. In fact some Basics back then only supported single or double letter variables. But we had Rem statements. Despite the use of sensible names, there are times when you need to document other things that are indirectly applicable to your code. For example the ranges of allowed parameters, or "Don't call this until after you have called Y...". Nowadays you have no excuse about commenting and open source comment extractors like the open source documentation generator Doxygen (for C and C++ and other languages) or the C# /// make life so much easier. Doxygen is worthy of a place in the C Code library.
资料 学英文 |
|
|