• (cs)

    "Don't ask. Don't tell", eh?

  • (cs)

    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.)

  • Kryptus (unregistered)

    I would have done something like this :

    var activePanel = panels[new Random().Next]; // Always works, don't ask !

  • Warren (unregistered)

    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.

  • McEgghead (unregistered)

    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?

  • lmm (unregistered)

    The question is not why KGX has a platform 0, but why lesser stations don't.

  • (cs)

    I'm not even going to ask.

  • Andrew (unregistered)

    What about "9"? Superstitious, perhaps?

  • p91 (unregistered)

    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.

  • TheSHEEEP (unregistered)

    What happens in ActionScript... stays in ActionScript.

  • Kasper (unregistered)

    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?

  • (cs) in reply to Kasper
    Kasper:
    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?
    I don't want to ask about any of them. I'm pretty sure I won't like the answer.
  • David (unregistered) in reply to McEgghead
    McEgghead:
    Why is there no "9" in the map, for one thing?
    Just... don't ask.
  • (cs) in reply to p91
    p91:
    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.
    My guess was similar: it started out as a way of having a 1-based array index, and then they started swapping around panels, possibly because they were deleted and recreated in the IDE or something like that. And then the index array was a really attractive option. But in that case, even enums would have made more sense. So, it's either something else or a CWTF (cluster-WTF).
  • (cs)

    This isn't TOO WTF-ish. It's a mapping, possibly from an older, legacy data structure into a new one.

  • van (unregistered) in reply to TheSHEEEP
    TheSHEEEP:
    What happens in ActionScript... stays in ActionScript.

    +1

  • (cs) in reply to lmm
    lmm:
    The question is not why KGX has a platform 0, but why lesser stations don't.
    I don't know whether it counts as a lesser station or not (but it hosts TGVs, so it can't be all bad), but the Lille Flandres station in Lille (France) has platforms numbered 0 to 15. Boringly, though, they left them in decimal rather than changing to 0-to-F.

    Curoiusly, the other main station in Lille, Lille Europe, has platforms numbered 43 to 46, for no particularly obvious reason.

  • Bruce W (unregistered) in reply to Andrew
    Andrew:
    What about "9"? Superstitious, perhaps?

    We don't need no stinkin' nines.

  • Pista (unregistered) in reply to Warren
    Warren:
    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.

    And that would be much more enterprisy than Philip's co-worker's lame solution :D

  • Harry Potter (unregistered)

    No platform 9.75 either :(

  • Oscar (unregistered) in reply to Andrew
    Andrew:
    What about "9"? Superstitious, perhaps?
    Octal.

    Well, maybe ninal, since they have both 0 and 8.

  • Numero Uno (unregistered) in reply to Lockwood
    Lockwood:
    a zero based system is just retarded.
    Troll is wrong. Even in grade school I noticed how broken the number system was:
     1  2  3  4  5  6  7  8  9 10
    11 12 13 14 15 16 17 18 19 20
    
    Notice something weird? All the items on the second line start with "1", except the last one. Where is its "1"? Check the row above!

    Compare with:

     0  1  2  3  4  5  6  7  8  9
    10 11 12 13 14 15 16 17 18 19
    
    Ahhh! Soothing.
  • Peter (unregistered)

    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.

  • Herr Otto Flick (unregistered) in reply to Numero Uno
    Numero Uno:
    Lockwood:
    a zero based system is just retarded.
    Troll is wrong. Even in grade school I noticed how broken the number system was:
     1  2  3  4  5  6  7  8  9 10
    11 12 13 14 15 16 17 18 19 20
    
    Notice something weird? All the items on the second line start with "1", except the last one. Where is its "1"? Check the row above!

    Compare with:

     0  1  2  3  4  5  6  7  8  9
    10 11 12 13 14 15 16 17 18 19
    
    Ahhh! Soothing.

    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.

  • (cs)

    TRWTF is "Indexes" amirite?

  • (cs)

    A zero based numbering system FOR BUS SERVICES is retarded.

  • kbiel (unregistered) in reply to Lockwood
    Lockwood:
    A zero based numbering system FOR BUS SERVICES is retarded.

    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.

  • Wolfraider (unregistered)

    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.

  • (cs)

    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.

  • (cs) in reply to Lockwood
    Lockwood:
    Kings Cross station has a Platform 0.
    Doesn't it also have a platform 9 3/4?
  • (cs) in reply to Lockwood
    Lockwood:
    Kings Cross station has a Platform 0.
    And a Platform 9¾. [image]
  • Hungry Number (unregistered) in reply to Andrew
    What about "9"? Superstitious, perhaps?
    I think 7 8 9.
  • Blackhat (unregistered)

    Obligatory xkcd - is already in the HTML comments!

  • (cs)

    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.

  • (cs) in reply to Herr Otto Flick
    Herr Otto Flick:
    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.
    In the US, you immediately sense impending danger when you have reached ground zero.

    Also google search "ground zero" for a bit more recent meaning of the term (although the fight club end scene is an uncanny forebode).

  • call this (unregistered)

    panelIndexes[9]

  • Garrison Fiord (unregistered)

    Where's the WTF? Pretty much every application I build has exactly this sort of code in it.

  • playing the cards (unregistered)

    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.

  • C-Derb (unregistered) in reply to Herr Otto Flick
    Herr Otto Flick:
    I think part of the reason that traditionally the UK has had better intrinsic programming skill than the US ....
    Really? I know I'm going to come across as a thin-skinned defensive US programmer, but I've never, ever heard anything about the "traditionally" superior talent on the other side of the pond. Care to support this? Or maybe I'm just getting trolled....
  • Publius (unregistered) in reply to Coyne
    Coyne:
    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.

    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.

  • inhibeo (unregistered) in reply to Coyne
    Coyne:
    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.

    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.

  • inhibeo (unregistered) in reply to Garrison Fiord
    Garrison Fiord:
    Where's the WTF? Pretty much every application I build has exactly this sort of code in it.

    You've got to be 60 years old, or something. Either way, I would retire you, with or without benefits.

  • (cs) in reply to kbiel
    kbiel:
    Lockwood:
    A zero based numbering system FOR BUS SERVICES is retarded.

    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.

    We're talking about FirstGroup and a schedule?! Really?

  • Garrison Fiord (unregistered) in reply to inhibeo
    inhibeo:
    Garrison Fiord:
    Where's the WTF? Pretty much every application I build has exactly this sort of code in it.

    You've got to be 60 years old, or something. Either way, I would retire you, with or without benefits.

    Butt-hurt Remy would rather modify my posts than learn some simple grammar lessons.

  • (cs)

    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?

  • (cs) in reply to Herr Otto Flick
    Herr Otto Flick:
    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.
    In the block of flats where I live, the buttons in the lift are numbered -1 (the car park under the building), 0 (the rez de chaussée (ground floor to you, Chuckles)), then 1, 2, ... 6 for the other floors.

    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.

  • (cs) in reply to Coyne
    Coyne:
    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

    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.

    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.

  • Gary (unregistered)

    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.

  • (cs) in reply to PedanticCurmudgeon
    PedanticCurmudgeon:
    Kasper:
    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?
    I don't want to ask about any of them. I'm pretty sure I won't like the answer.

    "A brain the size of a planet, and they ask me to map indices. Call that job satisfaction."

  • GMan003 (unregistered)

    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.

Leave a comment on “Ask the Index”

Log In or post as a guest

Replying to comment #:

« Return to Article