- 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
Oh syntax highlighter, how we love thee...
Admin
Those comments are pretty hilarious when read as code. Also,
:doing_it_wrong:
Admin
Yes indeed. Perpetuating the :WTF: without even opening a new backlog ticket to note intent to repair.
Admin
Admin
And then get reprimanded later for adding a time wasting ticket to the queue when there's "real work" to be done.
Admin
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."
Admin
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'.
Admin
I do believe the monsignor's finally got the point.
Admin
So does
MGM
represent a microgram, a milligram or a megagram?Admin
Admin
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.)
Admin
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.)
Admin
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.
Admin
mu--it represents the filmmaker Metro Goldwin Meyer.
<body isn't the sameAdmin
Or a megagram-meter?
Admin
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.
Admin
Yeah; I found it highly distracting to read as well...
[image]Admin
TRWTF is of course SAP...
Admin
As pointed out in the article:
Admin
:wtf:
Admin
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.
Admin
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.
Admin
It's by @Remy; always read the comments.
Admin
http://nypost.com/2014/02/16/book-reveals-real-story-behind-the-kitty-genovese-murder/
Admin
That author is well known (well, sorta) for sticking stuff in comments in their articles.
Admin
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>
Admin
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.
Admin
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.
Admin
He's trained me to look at the source for all articles now...
Admin
He's the only one I bother doing it for - have any of the others been caught doing it?
Admin
I catch some once in a while... Can't remember exactly who - hence I just check all.
Admin
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?
Admin
That's 6.022 × 1023 Gigabytes.
Admin
602 Zettabytes :Q___
Admin
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.
Admin
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.
Admin
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
Admin
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
Admin
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.
Admin
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.Admin
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.
Admin
All of this.
Admin
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.
Admin
That's 30 seconds. Then there's the...
...there's probably more; any good enterprisey company can come up with them by the dozens.
Admin
Oh the bureau crazy... :cry:
Admin
Just for reference, a Mega Gram (Mg) is better known as a "metric tonne". No it isn't the element Magnesium in this context.
Admin
FTFY :sob:
Admin
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.
Admin
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.
Admin
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.