• xorium (unregistered)

    So the for / switch paradigm but done badly.

  • PedanticRobot (unregistered)

    Slight nitpick, the QueryString struct is part of ASP.NET, not normal .NET. In regular .NET you can either roll your own query building or you can use HttpUtility.ParseQueryString(string.Empty) to get an instance of the private HttpQSCollection class that overrides NameValueCollection with a ToString() that will build the query string.

  • Industrial Automation Engineer (unregistered)

    yes, let's bash VBA once again, that's the real WTF. So what does a logical OR do? it takes two booleans (a bitfield of 1 bit) and does a bitwise OR. So, OR is always a bitwise OR in VBA, you just have to interpret the results correctly. As always: garbage in is foul ooze out.

  • (nodebb)

    So many programmers enjoy reinventing the wheel as an oblong triangle and just rolling with it.

  • (nodebb)

    Where's the part that checks whether i is 0 so it can use ? before the keyword instead of &?

  • Greg (unregistered) in reply to Industrial Automation Engineer

    In most other programming languages, the logical or will not evaluate the second clause if the first one is already true (that's what's called short-circuiting). It allows to do stuff like

    if( someClassInstancePtr != NULL or someClassInstancePtr->someMember ... )

  • (nodebb) in reply to Greg

    In most other programming languages, the logical or will not evaluate the second clause if the first one is already true (that's what's called short-circuiting).

    Sure, but VB has history and the maintainers have a long history of making sure that everything ever written continues to work. So, since "Or" historically didn't short-circuit (from like the dinosaur days), they instead added a new keyword. Your complaint would be reasonable for a language invented in the past 20 years, but not for one that had a lot of existing code in 1990.

  • (nodebb) in reply to Jaime

    Nitpick. This isn't VB6 or VBA. It's VB.NET, which is its own thing, and only vaguely compatible with the other two.

  • (nodebb)

    There might be a reason they did it this way with integer iteration: it preserves the order of the key value pairs. Usually the order doesn't matter, but they may want to preserve it for user readability or search engine/ analytics reasons.

    Also, the lack of "?" in the beginning means the query string already has some other parameters.

    The only WTF is that they have an exclusion check of one key, and inside of that if, they have an inclusion check of the keys they care about; the outside if isn't needed.

    Maybe the needed keys could have been put into a static readonly FrozenDictionary instance, for performance reasons, but that would be a micro optimization which would need to be tested and proven - i don't know if it would improve the performance.

    Addendum 2024-10-23 11:40: Also, the useless outside if has a useless ToString call, and calls Equals instead of using == operator, which is inconsistent with the rest of the code snippet; very minor WTFs. Overall, sorry but this article falls short.

    Addendum 2024-10-23 11:42: Correction, the outside if uses the <> operator, which is inconsistent with the Equals method calls elsewhere, but the point still stands - it's an inconsistency.

  • matt (unregistered)
    Comment held for moderation.
  • (nodebb) in reply to Jaime

    "Or" historically didn't short-circuit (from like the dinosaur days)

    and

    Your complaint would be reasonable for a language invented in the past 20 years

    C has done short-circuit logical evaluation ever since the beginning, you know, more than 50 years ago, so that "past 20 years"(1) could easily be "past 40 years" without even raising either a sweat or an eyebrow.

    (1) Heck "in the past 20 years" excludes languages invented in the 90s, or in, for example, 2000.

  • (nodebb)

    The obvious and simpler approach would have been to iterate across an array of the keys I care about- ID, new, FID, enabled, my, msgType, Type, EID, Title, ERROR- and simply check if they were in the Request.

    A reasonable algorithm you might say except that it doesn't preserve order as already noted (of course, if the collection is a NameValueCollection order is already not preserved) but also there is nothing in the HTTP URL standard that says keys in a query string must be unique. How the collection deals with this is dependent on the collection implementation, but I believe in this case you would get a comma separated list of all the values for the key.

  • (nodebb) in reply to Steve_The_Cynic

    C has done short-circuit logical evaluation ever since the beginning, you know, more than 50 years ago, so that "past 20 years"(1) could easily be "past 40 years" without even raising either a sweat or an eyebrow.

    I didn't say that no language has had short-circuiting in the past 20 years, I said that in the past 20 years, a language designer would be oblivious to not make or short circuit by default. In the 80's and 90's, language conventions weren't so well established regardless of how old C is.

  • (nodebb) in reply to Joe_D

    Nitpick. This isn't VB6 or VBA. It's VB.NET, which is its own thing, and only vaguely compatible with the other two.

    Notpick may be true, but Microsoft though very hard about getting people from VB to VB.Net and wanted to make the code work as is as much as possible. I taught a class when ASP.Net was first coming out and we gave the students a list of 10 things to do in asp pages so that they can be upgraded to ASP.Net by simply changing the file extension.

    Since C# didn't exist before then, the only code-free upgrade path was Classic ASP using VBScript to ASP.Net using VB.Net. They very much thought about making that use case as simple as possible.

Leave a comment on “Querieous Strings”

Log In or post as a guest

Replying to comment #:

« Return to Article