5.6. Practical Tips on Programming
The following list presents some practical tips on programming:
Always give your variables meaningful names. For simple loop counters, you can use i although loopCount probably describes the purpose of the variable much better. Don't prefix variables with the word var. All variables are variables, so adding var only adds noise to your code. Consider useful names such as _firstName and _categoryId as opposed to strFName or catI for private fields, and names like FirstName and Person for public properties and classes, respectively. The only exception to these rules is with the controls in your page — those are often prefixed with their type, like lstOperator to denote a list.
Experiment and experiment. Even more so than with working with controls and ASPX pages, the best way to learn how to program is by actually doing it. Just type in some code and hit Ctrl+F5 to see how the code behaves. The compiler will bark at you when something is wrong, providing you with useful hints on how to fix it. Don't be afraid to mess anything up; just keep trying variations until the code does what you want it to do.
Whenever possible, try to program together with somebody else. Nothing beats a game of pair programming where one person programs and explains what he does, while the other gives comments and asks questions. Swap places regularly, to put yourself in the other's position.
When writing functions or subroutines, try to minimize the number of lines of code. ...