- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
This is the first comment by position. Please do not use if blocks depending on count of comments.
Admin
Admin
nguid = Request.QueryString[Request.QueryString.Count-1]
Admin
TRWTF is the MMDDYY date format.
Admin
TRWTF is the NameValueCollection and its use to represent query parameters. I can think of only one possible reason behind that: to emulate how PHP works.
Admin
But that's just reiterating the original WTF - what if the parameter you want isn't at the last position?
Just pick the thing up by name and all the WTF-ery goes away
Admin
This reminds me of idiot consultants I used to work with. Always left huge chunks of code in, but commented out, because "what if we need that again?" and "looking at changes in source control is too hard"
a) What if you idiots understood the problem, and developed software to solve it? b) Learned to use the tools given you to see deltas over time.
Needless to say, it was orders of magnitude harder trying to figure out their shitty code with all this commented-out code laying around, so I always removed it.
Admin
and generated huge deltas for the rest of the team to look through. :-)
Admin
@Kamil Podlesak Ref:
So what would you propose should have been the way the Request object surfaces the querystring in a safe and easy to use manner?
Admin
The real problem is providing access to query parameters by index at all. These are named parameters by definition.
(What's you name? – The second one. – So it's "Secundus"? – No, it may be well the first one. – "Primus"? – No, really, you just have to get the first one, that is, most of the time.)
Admin
Our code is so full of #ifdef DEBUG_CONDITION that I've written an Emacs mode for hiding those blocks. Comments are the second bad thing; Old code parts in particular are more comment than code thanks to dated guidelines. Sadly, the comments describing the call interface of the functions are typically quite short, often only repeating what the function name already told me.
Admin
I'm guessing the parameters are coming back as a hash table and whatever this is coded in allows array indexing to be used on it.
Admin
As far as I remember, nothing in the CGI protocol guarantees that parameters will be in order in the query string (while they will be in practice). Even worse, empty parameters may be missing, as is the case for empty checkboxes. So the effective order varies, depending on the options chosen by the user. Access by index doesn't make sense at all. (If you subclass a general collection class, please, overwrite the default access by index, if there's any, as this raises unjustified expectations and provokes errors.)
Admin
How bout putting dem code changelogs in dem source repository commits?
Admin
"#ifdef DEBUG_CONDITION" may be quite valid if there are testing (with recompiles) on an ongoing basis.
Admin
are you the original developer?