Feed aggregator
White-Collar Jobs Freeze Triggers MBA Applications Boom
Read more of this story at Slashdot.
Foursquare To Kill Its City Guide App
Read more of this story at Slashdot.
Why is Apple So Bad at Marketing Its TV Shows?
Read more of this story at Slashdot.
Streaming Subscription Fees Have Been Rising While Content Quality is Dropping
Read more of this story at Slashdot.
Arm To Cancel Qualcomm's Chip Design License As Tech Feud Deepens
Read more of this story at Slashdot.
Teen Dies After Intense Bond with Character.AI Chatbot
Read more of this story at Slashdot.
Physicist Reveals Why You Should Run in The Rain
Read more of this story at Slashdot.
NASA Reveals Prototype Telescope For Gravitational Wave Observatory
Read more of this story at Slashdot.
CodeSOD: Querieous Strings
When processing HTTP requests, you frequently need to check the parameters which were sent along with that request. Those parameters are generally passed as stringly-typed key/value pairs. None of this is news to anyone.
What is news, however, is how Brodey's co-worker indexed the key/value pairs.
For i As Integer = 0 To (Request.Params().Count - 1) If (parameters.GetKey(i).ToString() <> "Lang") Then If (parameters.GetKey(i).Equals("ID")) OrElse (parameters.GetKey(i).Equals("new")) OrElse _ (parameters.GetKey(i).Equals("open")) OrElse (parameters.GetKey(i).Equals("FID")) _ OrElse (parameters.GetKey(i).Equals("enabled")) OrElse (parameters.GetKey(i).Equals("my")) OrElse _ (parameters.GetKey(i).Equals("msgType")) OrElse (parameters.GetKey(i).Equals("Type")) _ OrElse (parameters.GetKey(i).Equals("EID")) OrElse (parameters.GetKey(i).Equals("Title")) OrElse _ (parameters.GetKey(i).Equals("ERROR")) Then URLParams &= "&" & parameters.GetKey(i).ToString() URLParams &= "=" & parameters(i).ToString() End If End If NextThe goal of this code is to take a certain set of keys and construct a URLParams string which represents those key/values as an HTTP query string. The first thing to get out of the way: .NET has a QueryString type that handles the construction of the query string for you (including escaping), so that you don't need to do any string concatenation.
But the real WTF is everything surrounding that. We opt to iterate across every key- not just the ones we care about- and use the GetKey(i) function to check each individual key in an extensive chain of OrElse statements.
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.
I suppose the only silver lining here is that they thought to use the OrElse operator- which is a short-circuiting "or" operation, like you'd expect in just about any other language, instead of Or, which doesn't short circuit (pulling double duty as both a bitwise Or and a logical Or, because Visual Basic wants to contribute some WTFs).
[Advertisement] Plan Your .NET 9 Migration with ConfidenceYour journey to .NET 9 is more than just one decision.Avoid migration migraines with the advice in this free guide. Download Free Guide Now!
'Electric Plastic' Could Unleash Next-Gen Implants and Wearable Tech
Read more of this story at Slashdot.
UK-Based Dissident Can Sue Saudi Arabia For Alleged Spyware, Court Rules
Read more of this story at Slashdot.
San Francisco Muni's Rail System Will Spend $212 Million To Upgrade From Floppy Disks
Read more of this story at Slashdot.
Lawsuit Argues Warrantless Use of Flock Surveillance Cameras Is Unconstitutional
Read more of this story at Slashdot.
Peter Todd In Hiding After Being 'Unmasked' As Bitcoin Creator Satoshi Nakamoto
Read more of this story at Slashdot.
OpenAI, Microsoft Funding $10 Million In Grants For AI-Powered Journalism
Read more of this story at Slashdot.
Air Taxis and Other Electric-Powered Aircraft Cleared For Takeoff
Read more of this story at Slashdot.
Qualcomm Brings Laptop-Class CPU Cores To Phones With Snapdragon 8 Elite
Read more of this story at Slashdot.
Comic Sans Got the Last Laugh
Read more of this story at Slashdot.
More Than 10,500 Artists Unite in Fight Against AI Companies' 'Unjust' Use of Creative Works
Read more of this story at Slashdot.
UK Considers New Smartphone Bans for Children
Read more of this story at Slashdot.