-
-
Pages
-
Tags
3d desktop 5 dollars a gallon 6 Websites You Should Be Visiting Daily 100 NL 301 redirect 2007 affair all files all recorded music in history alpha centauri a memory of light american idol top 12 performances another computer apache apocalypse archival backup copy bad credit can be fixed beginners guide beryl Big John McCarthy Retires bittorrent blog books china css easy Games google how to HTML mma modx mod_rewrite PHP Poker Programming Review SEO UFC web development why wordpress yahoo zombies
-
Brian Rock
Why Commenting Your Programming Code Is Important
Programming is exact. Computers (for the time being at least) only know what you teach them, and only remember what you tell them to. They will not remember why your “func1()” is returning a “thingy” object, and neither will you. 6 months, or a year from now, you will be completely focused on some new project, and you will have to go back to that project, and you will look through notebooks, and thousands of lines and dozens of pages of code, trying to figure out what that function did.
You can make your situation better by using a proper function and variable naming convention. Proper naming conventions tend to be language specific at least, but there are some general rules of thumb. ConvertToCat is a much better function name than convcat for example. All caps are typically reserved for macros / global variables. Leading a function with _ is generally reserved for special cases, (like constructors in C#.NET). My point is that many developers tend to be lazy and abbreviate way too often.
Even with the best naming standards, there is still a need for comments. I was taught in my CS courses to comment every function start and end, arguments, and return values. Proper commenting and standards are especially important if you ever plan to work with other developers on a project. It is better to get in the habit of doing things in the proper way, than to pay the price of being lazy later. I can tell you from experience that you do not want to spend half a day trying to figure out what some function did and why you are using it in a certain way.
You Might Also Like...