Skip to Content
Beginning ASP.NET 3.5: In C# and VB
book

Beginning ASP.NET 3.5: In C# and VB

by Imar Spaanjaars
March 2008
Intermediate to advanced content levelIntermediate to advanced
766 pages
21h 15m
English
Wrox
Content preview from Beginning ASP.NET 3.5: In C# and VB

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. ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Beginning ASP.NET 4: in C# and VB

Beginning ASP.NET 4: in C# and VB

Imar Spaanjaars
Professional ASP.NET 3.5 SP1 Edition: In C# and VB

Professional ASP.NET 3.5 SP1 Edition: In C# and VB

Bill Evjen, Scott Hanselman, Devin Rader

Publisher Resources

ISBN: 9780470187593Purchase book