When you think ASP, think...
Recent Articles
All Articles
ASP.NET Articles
ASPFAQs.com
Message Board
Related Web Technologies
User Tips!
Coding Tips

Sections:
Sample Chapters
Commonly Asked Message Board Questions
JavaScript Tutorials
MSDN Communities Hub
Official Docs
Security
Stump the SQL Guru!
XML Info
Information:
Feedback
Author an Article
ASP ASP.NET ASP FAQs Message Board Feedback
Print this page.
Use prefix notation when naming your variables!


  • Back to Beginner's Tip Index
  • Next tip...

    If you give your variables names like i, j, x1, stuff, or blah, you are using poorly named variables, I assure you! Imagine reading through the code. You come across a statement like:

    x1 = 5

    Now what does that mean? x1 = 5? What is the coder trying to do? (This is particularly embarassing when you are reading your own code sometime later!)

    First off, you should choose variable names that make sense. If the variable is going to store the user's name, it should be named strName, not a or something nondescriptive. Also, you should use prefixes to convey the type of data you expect to be stored in these variables. Below is a short table of prefixes commonly used for various types of variables. Since all variables are variants in ASP, there is no formal or explicit type casting. (Although you can use casting functions such as CInt(), CStr(), etc.)

    Prefix Notation
    Integeri
    Longlng
    Singlesgl
    Doubledbl
    Stringstr
    Booleanbol
    Objectobj

    I strongly suggest you adopt this naming convention, or use your own. Regardless of the standard you choose, what is important is that you adhere to it! :) You'll note that the majority of code snippets on the site that I have written use the above prefix notation.

  • Back to Beginner's Tip Index
  • Next tip...


  • ASP.NET [1.x] [2.0] | ASPMessageboard.com | ASPFAQs.com | Advertise | Feedback | Author an Article