• (cs) in reply to DZ-Jay
    DZ-Jay:
    emptyset:

    DZ-Jay:

    He, he, he.  FYI: Yo hablo español, pero pensé que sería más divertido para la mayoría de los anglo-parlantes mezclar las lenguas en el nombre. :)

    <font face="Courier New" size="2">ah, muy bien.  ayudame entender: porque es que a los latinos le gusta agregar ASCII a los nombres de AIM, ICQ, etc. (fig 12)?  todos mis primos en venezuela tienen nombres asi.</font>

    <font face="Courier New" size="2">fig 12: ·#·$2(¯`•._.•·$PENDEJO·$2•._.•´¯)·$1Q</font>



    En mi experiencia, esas mariconadas cruzan fronteras culturales.

        -dZ.


    I confirm seeing  this "mariconadas" in Mexico but mostly in 14-year old teenage girls.
    /Mexican (at least until we are annexed by the States)
  • (cs) in reply to WTFer

    WTFer:

    I confirm seeing  this "mariconadas" in Mexico but mostly in 14-year old teenage girls.
    /Mexican (at least until we are annexed by the States)

    <FONT face="Courier New" size=2>she told me she was 28!  *purges AIM list*</FONT>

  • (cs) in reply to joe_bruin
    Anonymous:
    brazzy:
    John Smallberries:

    Why execute 50 session variable retrievals & string (actually variant) comparisons when 1 will do?


    How exactly do you think "else if" or select/case would reduce the comparisons to 1? If the cases were evenly distributed, you'd get 25 comparisons on average, by moving more populous states to the front you might get it down to 5 or so. Given the small size of the strings, that might even be faster than the hash-based solution.

    But speed isn't the issue here, code bloat is. The hash-based solution is the the right way to do it, because it doesn't duplicate code.


    You're under the impression that a switch/select statement gets reduced to a linear set of "else if" cases.  Luckily, you're not the one implementing our compilers, or we would all be screwed.  A good compiler usually generates a branch or jump table.  Implemented as a binary tree, this would mean O(log n) comparisons.  That's 3.9 average comparisons in our 50 states (4 comparisons in the worst case).


    Let's settle for log2 and 6 comparisons. Otherwise, I would have to ask you to prove you can do it in 4 comparisons.
  • (cs) in reply to joe_bruin
    Anonymous:
    Implemented as a binary tree, this would mean O(log n) comparisons.  That's 3.9 average comparisons in our 50 states (4 comparisons in the worst case).


    Actually, O(log n) could also mean 80000 comparisons for 50 states and 126052 comparisons for 500 states (although this numbers would be a WTF in the context of this task)
  • (cs) in reply to ammoQ

    ammoQ:
    Anonymous:
    Implemented as a binary tree, this would mean O(log n) comparisons.  That's 3.9 average comparisons in our 50 states (4 comparisons in the worst case).


    Actually, O(log n) could also mean 80000 comparisons for 50 states and 126052 comparisons for 500 states (although this numbers would be a WTF in the context of this task)

    I'm not sure how O(log n) gives 80000 for 50 states.  Can you elaborate?

  • Z (unregistered) in reply to ammoQ

    <FONT face="Courier New" size=1><script language="VBScript" runat="server">
     Function RenderStates()
      Const KEY = "StateStringArray"
      
      Dim sStates, sSelectedState, sSelected
      
      If IsEmpty(Application(KEY)) Then
       sStates = Array( _
        Array("", "State"), _
        Array("AL", "AL"   ), _
        Array("AK", "AK"   ), _
        Array("AZ", "AZ"   ), _
        Array("AR", "AR"   ), _
        Array("CA", "CA"   ), _
        Array("CT", "CT"   ), _
        Array("CO", "CO"   ), _
        Array("DC", "D.C." ), _
        Array("DE", "DE"   ), _
        Array("FL", "FL"   ), _
        Array("GA", "GA"   ), _
        Array("HI", "HI"   ), _
        Array("ID", "ID"   ), _
        Array("IL", "IL"   ), _
        Array("IN", "IN"   ), _
        Array("IA", "IA"   ), _
        Array("KS", "KS"   ), _
        Array("KY", "KY"   ), _
        Array("LA", "LA"   ), _
        Array("ME", "ME"   ), _
        Array("MA", "MA"   ), _
        Array("MD", "MD"   ), _
        Array("MI", "MI"   ), _
        Array("MN", "MN"   ), _
        Array("MS", "MS"   ), _
        Array("MO", "MO"   ), _
        Array("MT", "MT"   ), _
        Array("NE", "NE"   ), _
        Array("NV", "NV"   ), _
        Array("NH", "NH"   ), _
        Array("NJ", "NJ"   ), _
        Array("NM", "NM"   ), _
        Array("NY", "NY"   ), _
        Array("NC", "NC"   ), _
        Array("ND", "ND"   ), _
        Array("OH", "OH"   ), _
        Array("OK", "OK"   ), _
        Array("OR", "OR"   ), _
        Array("PA", "PA"   ), _
        Array("RI", "RI"   ), _
        Array("SC", "SC"   ), _
        Array("SD", "SD"   ), _
        Array("TN", "TN"   ), _
        Array("TX", "TX"   ), _
        Array("UT", "UT"   ), _
        Array("VT", "VT"   ), _
        Array("VA", "VA"   ), _
        Array("WA", "WA"   ), _
        Array("WY", "WY"   ), _
        Array("WI", "WI"   ), _
        Array("WV", "WV"   )  _
       )
       
       Application.Lock
       Application(KEY) = sStates
       Application.UnLock
      Else
       sStates = Application(KEY)
      End If</FONT>

    <FONT face="Courier New" size=1>  sSelectedState = Session("State")
      
      For i = 0 To 50  'The number of states is not likely to change
       If sSelectedState = sStates(i)(0) Then
        sSelected = " SELECTED"
       Else
        sSelected = ""
       End If
       
       Response.Write( _
        "<option value='" & sStates(i)(0) & "'" & sSelected & ">" & _
        sStates(i)(1) & _
        "</option>" _
       )
      Next
     End Function
    </script></FONT>

    <FONT face="Courier New" size=1><select class="f" name="State">
     <%=RenderStates%>
    </select>
     </FONT>

    <FONT face="Courier New" size=1></FONT> 

     

  • Trouble (unregistered) in reply to Z

    Washington D.C. isn't a state, and if you are going to include it in a state list for whatever reason you are going to have 51, not 50.

  • (cs) in reply to Trouble

    Anonymous:
    Washington D.C. isn't a state, and if you are going to include it in a state list for whatever reason you are going to have 51, not 50.

    Most lists of states include Guam, Puerto Rico, etc.  I've worked with lists of states that included Germany.

  • wiseass (unregistered) in reply to dubwai

    A time _complexity_ of O(log n) means the task is accomplished in
    (a+b*log n) steps for some constants a and b. Depending on the size of b, the above numbers are possible. Generally, O(x) does not say how long something takes, but how fast the time needed grows with the size of the problem. So, for small problems, an algorithm of O(2^n) can be faster than another algorithm of O(n).

  • (cs) in reply to wiseass
    Anonymous:

    A time _complexity_ of O(log n) means the task is accomplished in
    (a+b*log n) steps for some constants a and b. Depending on the size of b, the above numbers are possible. Generally, O(x) does not say how long something takes, but how fast the time needed grows with the size of the problem. So, for small problems, an algorithm of O(2^n) can be faster than another algorithm of O(n).

    I have a degree in Computer Science, but thanks.  I asked how you get that for 50 states where the state codes are 2 letters each.

  • AC (unregistered) in reply to emptyset
    emptyset:

    <font face="Courier New" size="2">fig 12: ·#·$2(¯`•._.•·$PENDEJO·$2•._.•´¯)·$1Q</font>



    ah, i see you speek Perl also :)
  • (cs)

    The killer is having 50 boolean variables, with only one of them being true.

    The fastest way to do this would require the developer to abandon the 50 individual boolean variables, perhaps replacing with a boolean array (IF YOU INSIST).  VB code migration can be eased by changing the 50 boolean variables into 50 integer constants to index the boolean array.

    A blazing fast lookup method would create a string variable with delimited state abbreviations and use the InStr() function to search all the two-character state abbreviations in one statement.  Special cases, such as "D.C." would require other checks.

    Example:

    <FONT face="Courier New"><FONT color=#0000ff>Dim</FONT> bStateSel(0 to 49) As Boolean
    <FONT color=#0000ff>const</FONT> selCA As Integer = 0
    <FONT color=#0000ff>const</FONT> selNY As Integer = 1
    <FONT color=#0000ff>const</FONT> selIL As Integer = 2
    <FONT color=#0000ff>const</FONT> selFL As Integer = 3
    <FONT color=#0000ff>const</FONT> selNV As Integer = 4

    strStateAbbr = "CA;NY;IL;FL;NV;"
    intStateIndex = <FONT color=#0000ff>InStr</FONT>(strStateAbbr, session("State") & ";")
    <FONT color=#0000ff>If</FONT> intStateIndex = 0 <FONT color=#0000ff>Then</FONT>
       'look for strange states such as "D.C."
    <FONT color=#0000ff>Else</FONT>
       'convert to bStateSel position value and update array
       intStateIndex = (intStateIndex -1) \ 3
       bStateSel(intStateIndex) = True
    <FONT color=#0000ff>End If</FONT></FONT>

    ======================
    Maybe it would be best to use the SelectedIndex property to immediately produce an index to the bStateSel array.

    Example:

    <FONT face="Courier New">intStateIndex = Document.OrderForm.State.SelectedIndex
    </FONT>bStateSel(intStateIndex) = True

  • (cs) in reply to wiseass
    Anonymous:

    A time _complexity_ of O(log n) means the task is accomplished in
    (a+b*log n) steps for some constants a and b. Depending on the size of b, the above numbers are possible. Generally, O(x) does not say how long something takes, but how fast the time needed grows with the size of the problem. So, for small problems, an algorithm of O(2^n) can be faster than another algorithm of O(n).



    wtf is this?  an eyechart?
  • (cs) in reply to dubwai
    dubwai:
    Anonymous:

    A time _complexity_ of O(log n) means the task is accomplished in
    (a+b*log n) steps for some constants a and b. Depending on the size of b, the above numbers are possible. Generally, O(x) does not say how long something takes, but how fast the time needed grows with the size of the problem. So, for small problems, an algorithm of O(2^n) can be faster than another algorithm of O(n).

    I have a degree in Computer Science, but thanks.  I asked how you get that for 50 states where the state codes are 2 letters each.



    No, you asked
     
    I'm not sure how O(log n) gives 80000 for 50 states.  Can you elaborate?

    In the formula (a+b*log n), choose 20000 for b and 1759 for a. Not a likely value for this kind of task (like I said before), just a justification about joe_bruin's wrong interpretation of O(log n)
    								<span class="txt2">
    									</span></span>
    
  • (cs) in reply to ammoQ

    "justification" is the wrong word, i meant "adjustment"

  • (cs) in reply to aikimark
    aikimark:

    The killer is having 50 boolean variables, with only one of them being true.

    The fastest way to do this would require the developer to abandon the 50 individual boolean variables, perhaps replacing with a boolean array (IF YOU INSIST).  VB code migration can be eased by changing the 50 boolean variables into 50 integer constants to index the boolean array.

    A blazing fast lookup method would create a string variable with delimited state abbreviations and use the InStr() function to search all the two-character state abbreviations in one statement.  Special cases, such as "D.C." would require other checks.

    Example:

    <font face="Courier New"><font color="#0000ff">Dim</font> bStateSel(0 to 49) As Boolean
    <font color="#0000ff">const</font> selCA As Integer = 0
    <font color="#0000ff">const</font> selNY As Integer = 1
    <font color="#0000ff">const</font> selIL As Integer = 2
    <font color="#0000ff">const</font> selFL As Integer = 3
    <font color="#0000ff">const</font> selNV As Integer = 4

    strStateAbbr = "CA;NY;IL;FL;NV;"
    intStateIndex = <font color="#0000ff">InStr</font>(strStateAbbr, session("State") & ";")
    <font color="#0000ff">If</font> intStateIndex = 0 <font color="#0000ff">Then</font>
       'look for strange states such as "D.C."
    <font color="#0000ff">Else</font>
       'convert to bStateSel position value and update array
       intStateIndex = (intStateIndex -1) \ 3
       bStateSel(intStateIndex) = True
    <font color="#0000ff">End If</font></font>

    ======================
    Maybe it would be best to use the SelectedIndex property to immediately produce an index to the bStateSel array.

    Example:

    <font face="Courier New">intStateIndex = Document.OrderForm.State.SelectedIndex
    </font>bStateSel(intStateIndex) = True



    I'm no VB expert but, I have never known substring searching to be blazing fast in any language.
  • (cs) in reply to ammoQ
    ammoQ:
    dubwai:
    Anonymous:

    A time _complexity_ of O(log n) means the task is accomplished in
    (a+b*log n) steps for some constants a and b. Depending on the size of b, the above numbers are possible. Generally, O(x) does not say how long something takes, but how fast the time needed grows with the size of the problem. So, for small problems, an algorithm of O(2^n) can be faster than another algorithm of O(n).

    I have a degree in Computer Science, but thanks.  I asked how you get that for 50 states where the state codes are 2 letters each.



    No, you asked
     
    I'm not sure how O(log n) gives 80000 for 50 states.  Can you elaborate?

    In the formula (a+b*log n), choose 20000 for b and 1759 for a. Not a likely value for this kind of task (like I said before), just a justification about joe_bruin's wrong interpretation of O(log n)

    I don't know what kind of iterpretation you are using for big notation, but the whole point is to ignore a + b.  When we are talking about the number or operations a specific task takes in the context of big O, it's generally assumed we are talking about the same high-level operations that contribute to the big O.

  • (cs) in reply to Mung Kee
    Mung Kee:

    I'm no VB expert but, I have never known substring searching to be blazing fast in any language.

    Depending on how it is implemented you might eventually have up to 147 string comparisons.
  • (cs) in reply to dubwai
    dubwai:

    I don't know what kind of iterpretation you are using for big notation, but the whole point is to ignore a + b.  When we are talking about the number or operations a specific task takes in the context of big O, it's generally assumed we are talking about the same high-level operations that contribute to the big O.



    The point is that the O notation does not give you the exact number of operations, only an indication about the growth of that number in relation to the growth of the input data.
    So, if some function has the complexity O(ln n), it's wrong to say that you need 4 operations for 50 input values.
  • (cs) in reply to ammoQ
    ammoQ:
    A Wizard A True Star:

    Oh, I've seen way better code than this. Applying the paradigm from the code I have to maintain, the above sample would look like this:

    <select class="f" name="State">
      <option value>State<!--</SPAN-->option>
      <option value="AL">AL<!--</SPAN-->option>
      <option value="AK">AK<!--</SPAN-->option>

    <FONT color=#008000>.. snip...</FONT>

      <option value="WI">WI<!--</SPAN-->option>
      <option value="WV">WV<!--</SPAN-->option>
    <!--</SPAN-->select>

    <FONT color=#000000> <SCRIPT>

    <font color="#000000">document.f.value = <font style="BACKGROUND-COLOR: #ffff00"><%</font>=Session("State")<font style="BACKGROUND-COLOR: #ffff00">%></font></font>

    <font color="#000000"></SCRIPT> </FONT></font>

    <font color="#000000"> <p><span style="COLOR: rgb(0,0,255)"><FONT color=#000000></FONT></span> </p> <p></p></font>
    <font color="#000000"> Much more pretty, but (in contrast to the WTF) depends on JavaScript. Some people turn it off for security (and other) reasons. Putting work from the server to the client is convenient but dangerous.</font>

    <font color="#000000"> <p>Sorry, I forgot to put a [sarcasm] tag around "better". I meant to say this code is far worse than today's WTF, for the reasons you mentioned (JavaScript can be disabled) and also for the very interesting side effect it has where the page loads, and a split second later, you actually see the contents of the dropdowns change.</p> <p> </p> </font>
  • (cs)

    Is the code of question of the day generated by a WYSWYG designers like Dreamweaver?

    The code reminds of that...

  • Hmm... (unregistered) in reply to A Wizard A True Star

    In principle you should be able to work with DHTML object server-side and then simply call some render method to generate the html. Might look something like this.

    <%
    Dim objSelect, _
            objOption, _
            objNode

    Set objSelect = Server.CreateObject("DHTML.Select")
    objSelect.Class = "f"
    objSelect.Name = "state"

    Foreach objNode in objValueCollection 'or whereever the entries comes from
        Set objOption = Server.CreateObject("DHTML.Option")
        objOption.Value = objNode.Key
        objOption.InnerHTML = objNode.Value
        If Session("state") = objSelect.Value Then
           objSelect.Selected = true
        EndIf
        call objSelect.Options.Add( objOption )
    Next



    Response.Write objSelect.toHTML

    %>

  • (cs) in reply to dance2die
    
            Is the code of question of the day generated by a WYSWYG designers like Dreamweaver?


    When I knew zip about ASP (three years ago), I had Dreamweaver write the code for me. Click, click, Repeat Region, MasterDetail click click etc.

    I thought I was being pretty cool.

    Trust me when I say this WTF's code is advanced and highly optimised compared to the shovelfuls of dirt Dreamweaver put on my screen.

    Though it's possible that Dreamweaver has improved bits and now actually does generate code with a semblance of cleanliness.
  • (cs) in reply to dubwai
    dubwai:

    Anonymous:
    Washington D.C. isn't a state, and if you are going to include it in a state list for whatever reason you are going to have 51, not 50.

    Most lists of states include Guam, Puerto Rico, etc.  I've worked with lists of states that included Germany.



    Our (the company's I work for) e-commerce sites include the state of Canada, and the little known states of Aypeow and Feepoe (APO, FPO, respectively, annexed surreptitiously during the NYC blackout of the 1970s).

    It also includes the Federated States of Micronesia (5 of them annexed sometime after the fall of Constantinople, the other 12 later joined in out of exhaustion) and the state of Palau (incorporated into the Union during the French Revolution).

    I think all of you need to update your lists (and maybe buy a new flag) since there is definitely more than 50 states.

        dZ.

  • (cs) in reply to AC
    Anonymous:
    emptyset:

    <font face="Courier New" size="2">fig 12: ·#·$2(¯`•._.•·$PENDEJO·$2•._.•´¯)·$1Q</font>



    ah, i see you speek Perl also :)


    That's no Perl...

    That's a Space Station!

        dZ.

    <font size="2">P.S. I have a very bad feeling about this...</font>
  • (cs) in reply to Hmm...
    Anonymous:
    In principle you should be able to work with DHTML object server-side and then simply call some render method to generate the html. Might look something like this.

    <%
    Dim objSelect, _
            objOption, _
            objNode

    Set objSelect = Server.CreateObject("DHTML.Select")
    objSelect.Class = "f"
    objSelect.Name = "state"

    Foreach objNode in objValueCollection 'or whereever the entries comes from
        Set objOption = Server.CreateObject("DHTML.Option")
        objOption.Value = objNode.Key
        objOption.InnerHTML = objNode.Value
        If Session("state") = objSelect.Value Then
           objSelect.Selected = true
        EndIf
        call objSelect.Options.Add( objOption )
    Next



    Response.Write objSelect.toHTML

    %>


    You make a good case against hungarian notation.
  • SvOlli (unregistered)

    Ah, he just wrote a simple code generation utility, and that's his testcase :)

  • (cs) in reply to Hmm...
    Anonymous:
    In principle you should be able to work with DHTML object server-side and then simply call some render method to generate the html. Might look something like this.

    <%
    Dim objSelect, _
            objOption, _
            objNode

    Set objSelect = Server.CreateObject("DHTML.Select")
    objSelect.Class = "f"
    objSelect.Name = "state"

    Foreach objNode in objValueCollection 'or whereever the entries comes from
        Set objOption = Server.CreateObject("DHTML.Option")
        objOption.Value = objNode.Key
        objOption.InnerHTML = objNode.Value
        If Session("state") = objSelect.Value Then
           objSelect.Selected = true
        EndIf
        call objSelect.Options.Add( objOption )
    Next



    Response.Write objSelect.toHTML

    %>


    I'm not exactly sure why but I think I'd feel dirty after providing a server-side DHTML solution.
  • (cs) in reply to ammoQ
    ammoQ:
    dubwai:

    I don't know what kind of iterpretation you are using for big notation, but the whole point is to ignore a + b.  When we are talking about the number or operations a specific task takes in the context of big O, it's generally assumed we are talking about the same high-level operations that contribute to the big O.



    The point is that the O notation does not give you the exact number of operations, only an indication about the growth of that number in relation to the growth of the input data.
    So, if some function has the complexity O(ln n), it's wrong to say that you need 4 operations for 50 input values.

    At the abstraction level that we mostly work in, it's pretty difficult to know exactly how many machine operations are required for any piece of code.

    In get your point now but hyperbole is rarely a good way to make a point.

  • htimsh (unregistered) in reply to DZ-Jay

    errr all you have to do is

    <font size="2"> selectBox.SelectedIndex = selectBox.Items.IndexOf( selectBox.Items.FindByValue( session("State").ToString() ) );</font>

    or am i missing something?

  • (cs) in reply to Mung Kee
    Mung Kee:
    Anonymous:
    In principle you should be able to work with DHTML object server-side and then simply call some render method to generate the html. Might look something like this.

    <%
    Dim objSelect, _
            objOption, _
            objNode

    Set objSelect = Server.CreateObject("DHTML.Select")
    objSelect.Class = "f"
    objSelect.Name = "state"

    Foreach objNode in objValueCollection 'or whereever the entries comes from
        Set objOption = Server.CreateObject("DHTML.Option")
        objOption.Value = objNode.Key
        objOption.InnerHTML = objNode.Value
        If Session("state") = objSelect.Value Then
           objSelect.Selected = true
        EndIf
        call objSelect.Options.Add( objOption )
    Next



    Response.Write objSelect.toHTML

    %>


    I'm not exactly sure why but I think I'd feel dirty after providing a server-side DHTML solution.


    I'd feel dirty after using the word 'DHTML'.
  • Z (unregistered) in reply to Trouble

    Anonymous:
    Washington D.C. isn't a state, and if you are going to include it in a state list for whatever reason you are going to have 51, not 50.

    True enough, but the size of this array is still unlikely to change.  (whether it's 5, 50, or 51)

  • Z (unregistered) in reply to Z

    Also, 50 in a zero-based array is element number 51.

  • (cs) in reply to DZ-Jay
    DZ-Jay:
    Volmarias:
    Oh, posh. Next you'll be telling me that it's a mistake to hard code every zip code? It was a lot of work, but by god, it was worth it.


    Hard coding every zip code is not a mistake if you keep a hard coded list of the particular city to which they belong.

        dZ.



    At least in the US, the USPS gives out a nice file that has all of the long/lat of each zipcode - including the city, state, and county. As an added bonus you get the type of post office supports that zipcode. Its not that big - my table for the US is just over 42k rows. After shoving that, ISO country codes, NPANXX codes, and state codes into the database I can provide the user with at least a fairly good guess of location.

    Still IP phones and number porting means that I have to accept limitations on the interface's ability to help the user along with filling out the form.
  • (cs) in reply to DZ-Jay

    DZ-Jay:
    Volmarias:
    Oh, posh. Next you'll be telling me that it's a mistake to hard code every zip code? It was a lot of work, but by god, it was worth it.


    Hard coding every zip code is not a mistake if you keep a hard coded list of the particular city to which they belong.

        dZ.

    This must be why I often have to argue with service representatives about where I live.

  • (cs) in reply to htimsh
    Anonymous:
    errr all you have to do is

    <font size="2"> selectBox.SelectedIndex = selectBox.Items.IndexOf( selectBox.Items.FindByValue( session("State").ToString() ) );</font>

    or am i missing something?

    I think the original code is "classic" ASP, not .Net.
  • Hmm.. (unregistered) in reply to dhromed
    dhromed:

    You make a good case against hungarian notation.

    I vbscript i allways prepend my variable names with either int, lng, str, bool, or obj. I don't do it in any other languages but it's really practical in vbscript functions or subs because you can easily see the type of the parameter that need to be passed;

    Function Foo( strMessage, intCount )
        Dim intIterator

        Foo = ""
        For intIterator = 0 To intCount
           Foo = Foo & strMessage & vbCrLf
        Nextv

    End Function

    Sub Bar( strMessage, intCount, strOut ByRef )
       

        strSub = ""

        For intIterator = 0 To intCount

           strSub = strSub & strMessage & vbCrLf

        Nextv

    End Sub

    With regard to the whole discussion about whether or not it's a good idear to use hungarian notation, can't we just agree that whatever notation you choose to do - use it consistantly.
    Mind you i only this notation for variable within a script. request paramters are just lower case with no indication of type.



  • (cs) in reply to Hmm..
    Anonymous:

    whatever notation you choose to do - use it consistantly

    Anonymous:

    I don't do it in any other languages...

    hmm...
  • (cs) in reply to Hmm..
    Anonymous:
    dhromed:

    You make a good case against hungarian notation.

    I vbscript i allways prepend my variable names with either int, lng, str, bool, or obj. I don't do it in any other languages but it's really practical in vbscript functions or subs because you can easily see the type of the parameter that need to be passed;

    Function Foo( strMessage, intCount )
        Dim intIterator

        Foo = ""
        For intIterator = 0 To intCount
           Foo = Foo & strMessage & vbCrLf
        Nextv

    End Function

    Sub Bar( strMessage, intCount, strOut ByRef )
       

        strSub = ""

        For intIterator = 0 To intCount

           strSub = strSub & strMessage & vbCrLf

        Nextv

    End Sub

    With regard to the whole discussion about whether or not it's a good idear to use hungarian notation, can't we just agree that whatever notation you choose to do - use it consistantly.
    Mind you i only this notation for variable within a script. request paramters are just lower case with no indication of type.



    Errr.

    Shouldn't that be:

    Sub Bar( vntMessage, vntCount, vntrefOut ByRef )

    [:)]

    After all, in VBScript there is no type but variant.

  • (cs) in reply to Hmm..
    Anonymous:
    dhromed:

    You make a good case against hungarian notation.

    I vbscript i allways prepend my variable names with either int, lng, str, bool, or obj. I don't do it in any other languages but it's really practical in vbscript functions or subs because you can easily see the type of the parameter that need to be passed;

    Function Foo( strMessage, intCount )
        Dim intIterator

        Foo = ""
        For intIterator = 0 To intCount
           Foo = Foo & strMessage & vbCrLf
        Nextv

    End Function

    Sub Bar( strMessage, intCount, strOut ByRef )
       

        strSub = ""

        For intIterator = 0 To intCount

           strSub = strSub & strMessage & vbCrLf

        Nextv

    End Sub

    With regard to the whole discussion about whether or not it's a good idear to use hungarian notation, can't we just agree that whatever notation you choose to do - use it consistantly.
    Mind you i only this notation for variable within a script. request paramters are just lower case with no indication of type.





    I suppose even I can see the value in this for parameter names in VB, since it's weakly typed.  It sets an expectation that otherwise would not exist.

  • Hmm.. (unregistered) in reply to Mike R

    correct: my hungarian worts denote the variant sub-type:

    Empty Variant is uninitialized. Value is 0 for numeric variables or a zero-length string ("") for string variables.
    Null Variant intentionally contains no valid data.
    Boolean Contains either True or False.
    Byte Contains integer in the range 0 to 255.
    Integer Contains integer in the range -32,768 to 32,767.
    Currency -922,337,203,685,477.5808 to 922,337,203,685,477.5807.
    Long Contains integer in the range -2,147,483,648 to 2,147,483,647.
    Single Contains a single-precision, floating-point number in the range -3.402823E38 to -1.401298E-45 for negative values; 1.401298E-45 to 3.402823E38 for positive values.
    Double Contains a double-precision, floating-point number in the range -1.79769313486232E308 to -4.94065645841247E-324 for negative values; 4.94065645841247E-324 to 1.79769313486232E308 for positive values.
    Date (Time) Contains a number that represents a date between January 1, 100 to December 31, 9999.
    String Contains a variable-length string that can be up to approximately 2 billion characters in length.
    Object Contains an object.
    Error Contains an error number.

    Since i'm anal-rententive it's something i like to keep track off throughout my program.
  • (cs)

    This is bad, but not quite to the level of a PowerBuilder app I saw.  Instead of implemeting a dropdown that contained all the states from a table, it made use of a datawindow and a radio button.  That's right, an entire window was devoted to selecting a state, unbelievable to me at the time.  But, now I see far worse things exist to maintain...

  • (cs) in reply to bigb
    bigb:
    This is bad, but not quite to the level of a PowerBuilder app I saw.  Instead of implemeting a dropdown that contained all the states from a table, it made use of a datawindow and a radio button.  That's right, an entire window was devoted to selecting a state, unbelievable to me at the time.  But, now I see far worse things exist to maintain...


    Assuming I understand you correctly....

    I had the displeasure of working with HTML DB (ships with Oracle 10g) which uses a new window for every multi-select, and just displays the items as a list of links.  Dreadful....positively dreadful.
  • Eric (unregistered) in reply to dubwai
    dubwai:

    Anonymous:
    Washington D.C. isn't a state, and if you are going to include it in a state list for whatever reason you are going to have 51, not 50.

    Most lists of states include Guam, Puerto Rico, etc.  I've worked with lists of states that included Germany.

    There are also a few "state" codes used by the US military to send mail to military bases in various regions of the world.

  • (cs) in reply to Eric
    Anonymous:
    dubwai:

    Anonymous:
    Washington D.C. isn't a state, and if you are going to include it in a state list for whatever reason you are going to have 51, not 50.

    Most lists of states include Guam, Puerto Rico, etc.  I've worked with lists of states that included Germany.

    There are also a few "state" codes used by the US military to send mail to military bases in various regions of the world.

    And it's not uncommon for Candanian provinces and Mexican states to be added to a list of US states at some point in the apps lifecycle.

    It's annoying when you want to enter a Canadian postal code but the software only allows numbers.

  • _travelinMan (unregistered) in reply to Mung Kee

    I've always wanted to go to ....  I heard it's beautiful this time of year.  I believe it's "The Eveything Else State".  Love it.

  • (cs)

    Maintain it?!?!? Burn it to the ground and start over. It would be faster.

  • (cs) in reply to dubwai
    dubwai:
    And it's not uncommon for Candanian provinces and Mexican states to be added to a list of US states at some point in the apps lifecycle.


    The Canadian province codes do not overlap the U.S. state codes.  Good design.

    It's annoying when you want to enter a Canadian postal code but the software only allows numbers.


    Or the other way around.  I was transferred to the U.S.  I tried to enter a change of address for one of my credit cards.  Said company's site does not accept addresses outside of Canada.

    I called about this.  It is deliberate policy.  A policy WTF.

    I was told that I should get a Canadian address.  I turned into a second-class citizen, because I am about one-half hour south of the border!  It was easier to quit dealing with them.

    Sincerely,

    Gene Wirchenko


  • Surf (unregistered)

    Looks like our wanna-be-programmer accidently removed all the </ </ body empty...< something by>

  • (cs) in reply to Mung Kee

    Mung Kee:

    I'm no VB expert but, I have never known substring searching to be blazing fast in any language.

    In this case, InStr() will be a much faster search than either <FONT face="Courier New">Select Case</FONT> or <FONT face="Courier New">If...ElseIF</FONT> constructs.  In general, recoding the search options often provides superb performance improvements over other string comparison methods.

    Note: doing case-insensitive searches with VB's InStr() function is not very efficient (maybe 8x slower than case-sensitive searches) and may be an instance where other methods or additional steps need to be taken.

    Another speedy option is to use hashing of the search arguments to allow numeric searching.

Leave a comment on “State Management”

Log In or post as a guest

Replying to comment #:

« Return to Article