Hungarian Notation useful in ASP?

Results 1 to 8 of 8

Thread: Hungarian Notation useful in ASP?

  1. #1
    keith5000 Guest

    Default Hungarian Notation useful in ASP?

    I&#039m wondering if anyone has applied the idea of Hungarian Notation to scripting languages used by ASP. Hungarian Notation is the practice of prepending variable-type abbreviations to variables (e.g. bStopLoop is a boolean, iNumPeople is an int, fnGetRandom is a function).<BR><BR>We wish to explore this practice where I work, but only if it&#039s useful for scripting languages (in which most variables are variant types).

  2. #2
    MG Guest

    Default RE: Hungarian Notation useful in ASP?

    Of course it makes since in VBScript. Even though all are variant, the prefix tells you what kind of data is the variable is intended for.<BR><BR>Some with swear by this while others don&#039t care. It is a matter of personal programing style.<BR><BR>

  3. #3
    KPW Guest

    Default RE: Hungarian Notation useful in ASP?

    I thought about this when I first started using VBScript. Eventually I decided that it did make sense to use Hungarian notation. As MG says, it helps you to know what kind of data the variable was intended to hold. Also, even though VBScript variables are all variants, there are variable subtypes, which basically correspond to VB&#039s normal data types. (As someone else on this board said, "Don&#039t ask me. I didn&#039t make up the language.")<BR><BR>Anyhow, using Hungarian notation in VBScript will help you stay consistent if you also program frequently in VB (in other words, you won&#039t start forgetting to use Hungarian notation in VB). Also, if you decide at some point to migrate some of your VBScript code to a VB COM DLL, you won&#039t have to spend time going through all your variables and adding the prefix. (Although in your Dim statements you probably would want to add the "as Integer", "as String", etc.)<BR><BR>HTH

  4. #4
    MG Guest

    Default Some like to do it this way

    Some like to do it this way so migrating to VB com is easier.<BR><BR>dim strMyString &#039as String<BR>dim intMyInteger &#039as Integer<BR>dim varMyVariant &#039as Variant<BR><BR>As you can see, you would only need to remove the tic to make it work with VB.

  5. #5
    KPW Guest

    Default That's great!

    I never thought about doing that, but it would definitely make migration faster.<BR><BR>Thanks for the tip -- hopefully I remember to start using that.

  6. #6
    KPW Guest

    Default More on that

    I was just doing some coding and realized that I DO do that (in a way). In my For...Next loops in VBScript, I usually do something like<BR><BR>For t = 0 to 5<BR><BR>Next &#039 t<BR><BR>In long For...Next loops it helps me keep straight which Next goes with which For. However, as I was coding just now I realized that this would also be helpful when migrating to VB COM.

  7. #7
    Join Date
    Dec 1969

    Default RE: Hungarian Notation useful in ASP?

    I usually try to follow this doc,<BR><BR>

  8. #8
    Join Date
    Dec 1969

    Default I still say Hungarian is a crock...

    ...but I don&#039t suppose anybody wants to hear or believe that.<BR><BR>Ah, well. Actually, I admit to slipping up an using iXXX (integer) or pXXX (pointer) from time to time. But I&#039m trying hard to stop doing that.<BR><BR>Not particularly relevant to this discussion, but...<BR><BR>Hungarian is actually a huge mistake with C++ and Java. You use it to describe a member variable, let&#039s say. Now you change your mind about the type of the variable. So you have to go change all occurences of the name. Blech. The whole point of strongly typed languages is that you *cannot* make a mistake. If you can avoid using casts except under the most dire circumstances (and you can, if you will plan ahead!), then you don&#039t bypass the checking of the compiler and it all works great!<BR><BR>The wonderful thing about scripting languages and Hungarian is that I might declare<BR><BR>Dim strValue &#039 as String<BR><BR>but if I then do<BR><BR>strValue = SomeRecordSet("someFieldName")<BR><BR>and that field happens to be a Date/Time field...well...what was the point of this again?<BR><BR>Even more fun is<BR><BR>Dim iValue &#039 as Integer<BR>iValue = Request.Form("someName")<BR><BR>since *all* values from Request.Form and Request.QueryString are strings.<BR><BR>Ah, as you will. MS has brainwashed the industry.<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts