• (disco)

    Oh syntax highlighter, how we love thee...

  • (disco) in reply to Tsaukpaetra

    Those comments are pretty hilarious when read as code. Also,

    so instead of spending five minutes to clean it up, he spent 30 seconds adding another if statement.

    :doing_it_wrong:

  • (disco) in reply to Fox
    Fox:
    :doing_it_wrong:

    Yes indeed. Perpetuating the :WTF: without even opening a new backlog ticket to note intent to repair.

  • (disco) in reply to Tsaukpaetra
  • (disco) in reply to Tsaukpaetra
    Tsaukpaetra:
    Yes indeed. Perpetuating the :wtf: without even opening a new backlog ticket to note intent to repair.

    And then get reprimanded later for adding a time wasting ticket to the queue when there's "real work" to be done.

  • (disco) in reply to DocMonster
    DocMonster:
    And then get reprimanded later for adding a time wasting ticket to the queue when there's "real work" to be done.

    If you're that chicken-scared of reprimands, you don't deserve your position.

    Seriously, TRWTF is perpetuating the vileness. This, of course, is probably what everyone else has done, and continue to do, which is why Apo has got another 300 urgent customer issue to attend to. They may well be caused by exactly such sloppy code.

    "I haven't got time to install a toilet, I'm too busy cleaning excrement off the floor."

  • (disco)

    Unfortunately, he was tackling the problem while juggling 300 other higher priority customer issues, so instead of spending five minutes to clean it up, he spent 30 seconds adding another if statement.

    TRWTF was not having the budget to prevent him from havnig to juggle 300 other high priority customer issues..therefore dangling the temptation of a quick 'fix'.

  • (disco) in reply to Fox

    Monsignor ...

    I do believe the monsignor's finally got the point.

  • (disco)

    So does MGM represent a microgram, a milligram or a megagram?

  • (disco)
    <tcaption>Price List</tcaption>
    ItemPrice
    Hardcoded if/elseif$49.95
    Hash map$99.95
    Standard code list mapping$149.95
    Database table mapping$999.95
    Not [image] Priceless
  • (disco)

    Really stupid question: if Apo is juggling 300 other "higher priority" issues, why touch this at all? If there are 300 higher priority issues, then 30 seconds spent hacking in another if() statement is five minutes too long.

    (Footnote: @CoyneTheDup overlooked the fact that there isn't an else in sight in the code. It isn't a hardcoded if/elseif. It's a hardcoded machine gun firing if() bullets.)

  • (disco) in reply to Tsaukpaetra

    I worked as a subcontractor on a government job once, and that was the policy. The project was really huge, and there was one guy who a large part of his job was to code review everything checked in to source control. He insisted that people do the absolute minimum of changes, and not touch anything else, because it made things like diffing changes more work for him. (I think the root of his reasoning was that we had to maintain multiple live branches for different customer and there was a lot of merging and this cut down on stuff he had to consider for potential merging to the various branches.)

  • (disco) in reply to Fox

    It turns out that the idea that everyone ignored Kitty's screams for help is not exactly true, but I don't remember the details.

  • (disco) in reply to dkf
    dkf:
    So does `MGM` represent a microgram, a milligram or a megagram?

    mu--it represents the filmmaker Metro Goldwin Meyer.

    <body isn't the same
  • (disco) in reply to dkf

    Or a megagram-meter?

  • (disco)

    I honestly don't see the problem with leaving this. The stacked statements are a bit ugly, but it's readable and maintainable (assuming the number of values doesn't climb too high). I wouldn't write the original code, but I also wouldn't bother rewriting it if I came across it.

  • (disco) in reply to Tsaukpaetra
    Tsaukpaetra:
    Oh syntax highlighter, how we love thee...

    Yeah; I found it highly distracting to read as well...

    [image]
  • (disco)

    TRWTF is of course SAP...

  • (disco) in reply to kjordan2001
    kjordan2001:
    TRWTF is of course SAP...

    As pointed out in the article:

    The Article:
    This might be a bit shorter than our usual CodeSOD, but this is a winner for WTFs-per-word, I think. No source control. Stupid code. Honest, but still stupid, comments. **And SAP**. Oh, and follow on developers compounding the problem. **And SAP**.
  • (disco) in reply to Steve_The_Cynic
    Steve_The_Cynic:
    **30 seconds** spent hacking in another if() statement **is** **five minutes** too long.

    :wtf:

  • (disco) in reply to PJH

    Well, it can't be overstated on how much of a WTF SAP is ;)

    Also, that's in the HTML comments of the article which I didn't read.

  • (disco)

    Welcome to my world of thousands of hardcoded string constants, used and not used (sometimes defined multiple times, sometimes also hardcoded in the logic, sometimes defined in a constants class), with multiple if/else statements, used in hashmaps to pass args, and so on.

    Always a mess and a hassle. And no, five minutes won't clean this mess up - maybe five months.

  • (disco) in reply to kjordan2001
    kjordan2001:
    that's in the HTML comments of the article which I didn't read.

    It's by @Remy; always read the comments.

  • (disco) in reply to FrostCat
    FrostCat:
    It turns out that the idea that everyone ignored Kitty's screams for help is not exactly true, but I don't remember the details.

    http://nypost.com/2014/02/16/book-reveals-real-story-behind-the-kitty-genovese-murder/

  • (disco) in reply to kjordan2001
    kjordan2001:
    Also, that's in the HTML comments of the article which I didn't read.

    That author is well known (well, sorta) for sticking stuff in comments in their articles.

  • (disco) in reply to RFoxmich
    RFoxmich:
    > Unfortunately, he was tackling the problem while juggling 300 other higher priority customer issues, so instead of spending five minutes to clean it up, he spent 30 seconds adding another if statement.

    TRWTF was not having the budget to prevent him from havnig to juggle 300 other high priority customer issues..therefore dangling the temptation of a quick 'fix'.

    But if each of those 300 high priority issues can be fixed in 30 seconds, he should have no trouble getting through all of them in one day.

    </manager>

  • (disco) in reply to Dragnslcr
    Dragnslcr:
    But if each of those 300 high priority issues can be fixed in 30 seconds, he should have no trouble getting through all of them in one day.

    And if he can't, then we can just assign two new developers to work with him and get everything done in a third of the time. Easy.

  • (disco)

    Actually, using a hash map where 4 trivial if-else statements do the job is neither more readable, nor more performant, so using a hash map would have been TRWTF.

  • (disco) in reply to PJH
    PJH:
    That author is well known (well, sorta) for sticking stuff in comments in their articles.

    He's trained me to look at the source for all articles now...

  • (disco) in reply to dcon
    dcon:
    He's trained me to look at the source for all articles now...

    He's the only one I bother doing it for - have any of the others been caught doing it?

  • (disco) in reply to PJH

    I catch some once in a while... Can't remember exactly who - hence I just check all.

  • (disco)

    Kelvin Gigabytes? Some sort of measurement of temperature-dependant memory storage?

    Mole Gigabytes? Some sort of mesurement of the number of molcules needed for memory storage?

  • (disco) in reply to Jonathan_Harston
    Jonathan_Harston:
    Mole Gigabytes?

    That's 6.022 × 1023 Gigabytes.

  • (disco) in reply to NedFodder

    602 Zettabytes :Q___

  • (disco)

    Implementing three comparisons as an Hash Map would be a performance and memory killer.

    Additionally, MGM stands for what ? MegaGrams (Tons) ? Milligrams ?

    Definitely, not an Hash Map. And a clever comparison would be searching first for "GM" at offset 1 and then compare the other three variants at offset 0.

    Apparently you all don't know how an hash map is implemented.

  • (disco) in reply to Alvaro_Lopes

    If it's just 4 comparisons, and they're never going to change, what's here is reasonable, if rather soul-destroying. If the set of supported units is likely to change, or the mapping isn't fixed, then another solution is less miserable.

  • (disco) in reply to dkf

    None of those are acceptable scientific unit abbreviations involving grams.

    microgram: μg milligram: mg Megagram: Mg

    MGM as was suggested earlier must be a unit of movies - the Metro Golden Meyer. Which is also neither a CGS nor MKS unit.

    There is some non-scientific standard that says that MGM is obsolete mg and that the correct usage is now ME This, however is not science but some body calling itself the produce trace-ability initiative

  • (disco) in reply to dkf

    You have to weight the impact if more "replacements" are to be made, that is for sure. May be feasible for let's say more than 6 entries.

    Problem is TFA clearly suggests using an hash map on this particular case, which will only add memory usage, and processing will be about the same (that surely depends on the hashing function and how many other items exist [their size being most important]).

    Alvie

  • (disco) in reply to Alvaro_Lopes
    Alvaro_Lopes:
    May be feasible for let's say more than 6 entries.

    For a small fixed set of values, whatever. Almost any technique works wonders when used with minuscule N.

    However, what really matters most of the time is the cost of maintenance, given that modern computers are actually incredibly fast (and would be faster if they didn't run monstrosities like SAP, but I digress…) Something slightly slower to execute might be justifiable if it makes it possible to do other things more easily. It is entirely possible that using a mapping table kept externally might make adapting to changing requirements simpler, or it might mean you can get rid of having special cases and instead keep a more generic processing engine.

  • (disco) in reply to Steve_The_Cynic
    Steve_The_Cynic:
    (Footnote: @CoyneTheDup overlooked the fact that there isn't an else in sight in the code. It isn't a hardcoded if/elseif. It's a hardcoded machine gun firing if() bullets.)

    No, I didn't: that should be read that the pricing is the same for if or elseif (and including any else)...at least as I conceived my joke.

    There's also a subtext: if you were paying really close attention, you would also have noticed that 3 if statements was $149.97; for $.03 more, the customer could have got a code mapping.

  • (disco)

    Are you all under the impression that the three if statements (four including the outside if) in the article represent the entire function and :wtf:, and hasn't been trimmed down from thousands of similar lines? YMBNH.

    Yeah, if there are three comparisons, what they have is perfectly fine and there's nothing to see here, move along. However, if they have hundreds of such comparisons, then using some kind of hash map (probably nested map / dictionary, based on the outside if statement) would make a lot more sense for maintainability, if not also performance.

  • (disco) in reply to prueg

    All of this.

  • (disco) in reply to Fox

    IMO, modifying the code to switch statement shouldn't need more than 30 seconds too, unless the "if" lines are more than what's shown here.

  • (disco) in reply to cheong
    cheong:
    IMO, modifying the code to switch statement shouldn't need more than 30 seconds too, unless the "if" lines are more than what's shown here.

    That's 30 seconds. Then there's the...

    • Work request
    • Customer engagement form
    • Project plan
    • Design document
    • Architecture review
    • (code change)
    • Code review
    • QA documentation
    • QA meeting to review the changes
    • QA testing
    • Implementation plan (including back-out)
    • Technical documentation
    • Installation
    • Post implementation review
    • Post implementation announcement document

    ...there's probably more; any good enterprisey company can come up with them by the dozens.

  • (disco) in reply to CoyneTheDup

    Oh the bureau crazy... :cry:

  • (disco)

    Just for reference, a Mega Gram (Mg) is better known as a "metric tonne". No it isn't the element Magnesium in this context.

  • (disco) in reply to CoyneTheDup
    CoyneTheDup:
    there's probablymany more

    FTFY :sob:

  • (disco)

    I really don't see the WTF.

    Unless there is a a requirement for this to be user configurable or localisable, whether the implementer used an if / else if ladder, a switch statement or a hashmap is kinda trivial. They all do the same thing, and IMHO unless it really needs to be user configurable, I'd rather see this than some astronaut architect's wet-dream which loads the mapping from an XML document served via a web service that generates it dynamically from the contents of a visio diagram.

  • (disco) in reply to herby
    herby:
    Just for reference, a Mega Gram (Mg) is better known as a "metric tonne". No it isn't the element Magnesium in this context.

    You can also chain them together. I once had to fix some PLC code where the original author had obviously lost his mind. He defined a unit of energy known as MILLI_KILOWATT_HOURS, in order to store fractional kilowatt hours in a UINT32. Poor bastard.

  • (disco) in reply to CoyneTheDup
    CoyneTheDup:
    That's 30 seconds. Then there's the...

    You missed the FAT, EAT, SAT, CAT, UAT and any other acceptance test that hasn't yet used a letter of the alphabet.

    These are great, cause they create an opportunity to restart the entire process if any of them fail.

Leave a comment on “Leaving an Honest Comment”

Log In or post as a guest

Replying to comment #460361:

« Return to Article