- 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
"Don't ask. Don't tell", eh?
Admin
Kings Cross station has a Platform 0.
First Hampshire are renumbering their bus routes soon, with them going to a sequential number system rather than grouping numbers based on route (Waterlooville being 4x, Gosport being 8x, etc). These numbered routes are, of course, starting with the number zero service.
(Kings Cross got an extra platform added next to Platform 1, so it made sense for that to become P0, with them doing a renumber once all the station works are completed. Didn't stop me making a load of "Platforms are both 0-based and 1-based! The memories are returning!!!" jokes. First changing to a zero based system is just retarded.)
Admin
I would have done something like this :
var activePanel = panels[new Random().Next]; // Always works, don't ask !
Admin
Am pretty sure this should form a SQL table. That way, each time you want to resolve the true number of a number you can simply hit the DB server.
Admin
I would feel compelled to ask, even though I understand why the source of this "code" would rather I didn't ...
Why is there no "9" in the map, for one thing?
Admin
The question is not why KGX has a platform 0, but why lesser stations don't.
Admin
I'm not even going to ask.
Admin
What about "9"? Superstitious, perhaps?
Admin
Hm, are you sure this is a WTF? I wrote something similar once as a mapper between the logical line of a panel and the wired hardware lines. This resultet in somethin simiar as above.
Admin
What happens in ActionScript... stays in ActionScript.
Admin
The "Don't ask" comment only applies to one of the lines. You may want to ask about the previous 11 lines. Or should we say 2?
Admin
Admin
Admin
Admin
This isn't TOO WTF-ish. It's a mapping, possibly from an older, legacy data structure into a new one.
Admin
+1
Admin
Curoiusly, the other main station in Lille, Lille Europe, has platforms numbered 43 to 46, for no particularly obvious reason.
Admin
We don't need no stinkin' nines.
Admin
And that would be much more enterprisy than Philip's co-worker's lame solution :D
Admin
No platform 9.75 either :(
Admin
Well, maybe ninal, since they have both 0 and 8.
Admin
Compare with:
Ahhh! Soothing.Admin
Must be code for an embedded system. I'd be worried if I didn't see something like this. Crazy addressing schemes are the norm for display panels and the like.
Admin
Troll wasn't a troll, you just clipped context from his quote to make him look like a troll. His full sentence was
"First changing to a zero based system is just retarded"
Which itself is doing a disservice, because I've clipped the context that makes that sentence:
"First changing to a zero based system [and then back to one based] is just retarded"
I think part of the reason that traditionally the UK has had better intrinsic programming skill than the US is that we are 0-based on most things, eg floors. In the US, the ground floor is '1', where as in any sane system it is '0' or 'Ground floor', and the first floor is what your average american would call the second floor.
Of course, this matters less now that programming doesn't require any mental skill.
Admin
TRWTF is "Indexes" amirite?
Admin
A zero based numbering system FOR BUS SERVICES is retarded.
Admin
Only if you assume that the bus services are there to serve riders and not to give bureaucrats and their IT departments jobs. Now the platform numbering system is the index into the schedule instead of a arbitrary key that needs to be mapped to a schedule.
Admin
I am thinking this was used to set the tab order. At least that's what came to my mind. Someone decided that they wanted a different order at some time but it is a little odd to be set this way.
Admin
That looks something like that "dependent" coding in an insurance system I worked on one time (best recollection):
01 - spouse 02 - first child 11 - first adult dependent 12 - second child 21 - second adult dependent 22 - third child 23 - fourth child 24 - fifth child 98 - any additional children
I think this is also a, "Don't ask."
But it's interesting to make a system count 02, 12, 22, 23, 24, 98, 98, 98 for children because the requirement was that these could not be used out of order.
So if the user just put in a 12 for a single child, it would get rejected because there was no 02 coding. So we either had to edit for that or else compute the numbering; moreover, the rows had to be re-coded if a child was removed.
Admin
Admin
Admin
Admin
Obligatory xkcd - is already in the HTML comments!
Admin
Panels could be GUI elements. If you are re-sizing them in code, you usually need to iterate through them. If the programmer was told to order them one way, and then after that had been programmed, had been told to order them another way, the result would be the WTF, through no fault of the programmer.
Admin
Also google search "ground zero" for a bit more recent meaning of the term (although the fight club end scene is an uncanny forebode).
Admin
panelIndexes[9]
Admin
Where's the WTF? Pretty much every application I build has exactly this sort of code in it.
Admin
This definitely resembles the bidding process in Skat, a card game popular over here in Germany. Bidding happens using the numbers 18, 20, 22, 0, 24, 27, 30, 33, zero hand, 36, 40, 44, 45, 46, 48, … (well, I guess you have figured out the system by now!) in that order. Pretty obvious system, which (encoded in a computer version of that game) could lead to pretty similar-looking code.
Admin
Admin
But wait, your story gets better. Then they append these codes to the contract number and use it as a primary key for patient identification. Works great until membership realizes Susie and Johnny were born in the opposite order, and swap their dependent IDs around. Now when a claim comes in as 99999999-12, it's ambiguous, and you end up with records that indicate children have had vaccinations 3 years before they were born... WTF indeed.
Admin
Old programmers are really retards. Why code each case, when you clearly have data that you can use to sort these things (e.g. birth date). In addition to that, transitions between child to adult (e.g from 02 to 11) isn't going to be automatic in that system.
Admin
You've got to be 60 years old, or something. Either way, I would retire you, with or without benefits.
Admin
Admin
Admin
Where's the WTF? It's a map from string to an index. Why should the map have an entry for "0" or "9"? And why should they be in the order you think?
Admin
British lifts are often marked B, G, 1, 2, ... whereas the French seem to prefer fully-numeric markings like the ones in my flat's lift.
Admin
Leave us not forget that there is a context in which we learned to count 1, 2, 3, 95, 98, 2000, Me, XP, Vista, 7, 8.
Admin
I thought for a minute that this was my code.
Long ago, in the days before jQuery-ui, in the days before prototype.js, in the days before scriptaculous, there were no simple html ui libraries - or people rolled their own and sometimes they sucked. Or sometimes they were implemented in a sucky way.
The panels here are likely tabbed panels in a UI or something similar. Someone decided to reorder them at some point, and the easiest way somehow was to "rename" them rather than - well, a million other ways of doing it.
Admin
"A brain the size of a planet, and they ask me to map indices. Call that job satisfaction."
Admin
That's not all that odd - I have similar things in much of my code.
For our project, we had to integrate with the various (mutually-competing) vendors' products. While they all did roughly the same thing, they have different APIs.
I didn't feel like writing and maintaining a half-dozen versions of the same code, so I naturally abstracted the core functionality out into a library. The vendor-specific code is basically just decoding a request (some use XML-based formats, others use JSON, or send SOAP requests, and one uses CSV files).
But a common thing I needed to do was map "their" identifier for a given operation into "out" identifier. For instance, is a charge a "charge", a "withdrawal", or a "negative account adjustment", or some integer enum type?
And the easiest way to do that was using a similar keyed array, using "their values" as the key and "our values" as the value. It sure beats a bunch of semi-readable if-else blocks or a massive switch statement, especially if needed several times. I could even put the array into a config file and make it user-configurable. I could, that is, but I know better than to give users that kind of power.
So I'd kind of have to see the context this code was being used in before declaring it a true WTF.