- 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
Packed decimal on an S/390 uses one decimal digit per nibble. The last nibble contains x'F' for unsigned numbers, and x'C' (positive) or x'D' (negative) for signed numbers. You can redefine a 7-digit packed number ((7+1)/2=4 bytes) as two 3-digit packed numbers (each (3+1)/2=2 bytes).
Assigning zero to the 7-digit number (signed) would result in:
x'0000000C'
Assigning zeroes to both 3-digit nimbers would result in:
x'000C000C'
Assigning -1000 to the 7-digit number:
x'0001000D'
The second 3-digit number contains x'000D', negative zero. The first number is not a valid packed decimal value, but if I remember correctly it would still be interpreted as positive or negative zero by the hardware.
I don't remember having trouble comparing positive and negative zeroes in COBOL. It's been more than 10 years since I last used it, but I think it would remember it as a mayor issue if -0 != +0. But when you redefine numbers in this way you loose all type safety and wierd things can happen.
Admin
Okay, when you said it I looked up and saw that. But I was playing zork just recently and I haven't grew up in that geek culture.
Admin
public static poopstrings { public static Poop = "I'm the poop."; public static Poop_Location = "Here.";
}
Admin
NaN is represented by one distinct bit pattern.
+0 and -0 are, OTOH, different bit patterns, courtesy of the sign bit.
See?
No. And no one implied anything like that. You can however use them if you see fit, and in that case, see above: Different bit patterns, therefore correctly considered as different keys.All wrappers do implement equals() and hashCode() in a consistent way in order to support their use in collections - yes, also as keys, and yes, all of them. Whether Doubles (or Floats, at that) are an apt choice for keys in hashing collections is in fact debatable, but it is certainly not an error per se as long as the contracts are fulfilled, which is precisely the reason for these two exceptions.
We are having more than enough trouble with people using home-grown mutable (!) classes as keys in hash tables, with equals()/hashCode()-methods, which either are not implemented (i.e. overridden) in the first place or blatantly ignore the necessary contracts and/or are not implemented as a consistent pair. Afterwards the same people blame the collections for malfunctioning and abysmal performance.
I prefer even Double/Float-instances used as keys over that at any given time, because it is at least correct, thank you very much.
Apart from the compelling reason given above, there are ways to yield -0 as result of mathematical operations (e.g. lim) or arithmetic underflows (if you care to call this mind-boggling), and you have to jump through some (mostly non-portable) hoops in most other languages to check for -0 in such cases. See e.g. http://en.wikipedia.org/wiki/Negative_zeroThe way this wrapper is implemented is obviously a way to guarantee correct behaviour in case someone does (perhaps not very intelligently) use Doubles/Floats as keys in a hash table, without having to resort to any exceptional handling inside the collection itself. The algorithm is without doubt sensible, as it does never make any exceptions to the "each key exactly once in a hash table"-rule. The (not really very) exceptional behaviour for Doubles/Floats to guarantee this is IMHO in quite good hands inside these wrapper classes - Josh Bloch et al. are not stupid.
Should some of the wrappers behave in a different way that would in fact break correct hash table behaviour, or - even worse - should the hash table handle this special cases itself it would really be a major WTF and I'm sure you'd sneer at that too, am I right? ;o) And you should, nota bene... I would gladly second that.
Admin
"A man was going down from Jerusalem to Jericho, when he fell into the hands of robbers. They stripped him of his clothes, beat him and went away, leaving him half dead. A priest happened to be going down the same road, and when he saw the man, he passed by on the other side. So too, a Levite, when he came to the place and saw him, passed by on the other side. But a Samaritan, as he traveled, came where the man was; and when he saw him, he took pity on him.
"It is pitch black," said the Samaritan. "You are likely to be eaten by a grue."
"What is a grue?" sayeth the naked and beaten and half dead man, for no other reason than that the plot of the game requireth it.
"The grue is a sinister, lurking presence in the dark places of the earth. Its favorite diet is adventurers, but its insatiable appetite is tempered by its fear of light. No grue has ever been seen by the light of day, and few have survived its fearsome jaws to tell the tale."
"OK," sayeth the man, "that all makes sense to me now. All that stuff about the Levite and the Pharisee was just filler, wasn't it?
"Why didn't you just mention the grue in the first place?"
"Because you have to ask," said Jesus. "That's how the Gospel works on the DEC PDP-10."
... the Gospel According to Aardvark, 9:22.
Admin
You're in a mess of public static Strings, all alike...
Admin
Not me. I have a light!
Admin
If you're running on a sign-magnitude architecture, assembly language has no trouble with negative zero.
Admin
Alex,
I think there is a bug in DailyWTF. When i try to close my eyes to visualise with you, I cannot see your blog anymore.
Admin
I am happy to report that I am more like BK than the original poster. However, BK is not nearly emphatic enough.
I cannot think off-hand of a worse place to start a programming project than a constants file.
Oh, wait. I got it. How about by creating your database before you've written a single line of code? That'd be brilliant. Or not; on second thought, that's not quite as bad as a 'constants' file: it's generally easier to rebuild a database when you've found out you need to than it is to break out of the mental trap that is having a 'constants' file.
For what it's worth, when I'm fully in charge of the project, the first line of code goes in a file with a 't' extension, in a 't' directory. Otherwise, it's probably going to be whatever file will contain the language's equivalent to main() - but don't worry, I'll be in others before long.
Admin
A grue won't even eat you then. You can sit around in pitch black darkness for hours - days, even - without getting eaten by a grue.
Grues only eat you if you move around after it's pitch black.
Admin
You're right! I'll take a crack at it...
Admin
Now it should have been entirely obvious to anyone that class _1269 is the first letter of the hurricane names for each season. The missing Q and U, and the fact it ends with W, totally give it away.
...Oh, wait, the "V" is missing, too. Hmmmm.....
Okay, it's the hurricane list alright, but you're right: It's not finished.
Admin
We're lost in a twisted maze of little constants, all different.
Admin
I once worked in a Cobol shop that had made a transition to Java. However, for some reason they decided to stick to the naming scheme of Cobol for naming their classes.
The result: class names of exactly eight letters or digits, with all letters in uppercase. For example: CUAPT32V.
Admin
Love the way the voice cracks on every 'static', captures the mood of this WTF very brillantly
Admin
Now THIS is an efficiently code, even people that does'nt understand codes could use it!
I'm thinking of using similary code, but instead of variable names like "_A", i would use arrays that will cause serious confusion :)
Admin
well, the real WTF is, that you cannot see the performance-gain that occures when you use the classes.
I mean, this is Java, isn't it?
In Java Strings are immutable, so predefining these Strings you keep them in Memory and don't waste time allocating Memory for new Strings - You even dont's have to rely on garbage collection to get new free memory for your Strings - You cannot run out of memory allocating a new String, because they all are already there!
brilliant!
Admin
I'm sorry, but are you serious?
Admin
Priceless: the Great Unifying Constant (GUC)
Admin
Peaceful meadow .... check. Mailbox ........... check.
Hang on... isn't there something missing?
zOMG THEY ATE THE WHOLE GODDAM HOUSE!!! RUN!!!!!!1!!!
Admin
Think a situation where the United Nations Commitee of Changing Numbers Againts Commons Sense, the UNCCNACS, decides to substitute the number 14 with some other value! It will be much easier to fix the code when every reference to 14 is in constants.
Makes sense for me.
Admin
Anybody already mentioned "String Pooling"? Yes, "String Pooling". It's cool! It saves a few bytes... oh, and Java does it automatically actually. No need to bother with string constants like these.
Admin
Looks like a new incarnation of the bible code...
Admin
Admin
This reminds me of an April Fool's joke that my colleagues and me played once. I'm sure isn't original, but it worked very well on one of the other developers there.
We were programming in C, and one of the rules was that there should be no "magic numbers" or other constants in the code; these should all be #defined in a header file. So, we made a header file (generated with a small program) that looked like this:
#define ZERO 0 #define ONE 1 #define TWO 2 #define THREE 3 /* snip */ #define NINEHUNDREDANDNINETYEIGHT 998 #define NINEHUNDREDANDNINETYNINE 999 #define THOUSAND 1000
We presented this to our fellow developer and she freaked out. She: "You're not seriously going to do this, are you?!", we: "Yes, we've already implemented this though all the code!". It was funny.
Admin
Admin
Around here (in Europe) VB skills are worth €500/day or some €120,000 (or, currently, some $180,000) per year (could be more, though, depending on the project).
Now what??? Who is stupid, my Dear?
Admin
Admin
So, tell us the secret. Don't go too much into detail as there are three Old Continents. But who cares, anyway?
Admin
dont worry, after all TopCodr, or TC as we like to call him round here, actually can earn anything in the following range
9001 <= TC <= Integer.MAXIMUM
after all since its clear that no one would ever earn an annual salary with cents attached its a significant space improvement to store wages in an Integer field.
Oh and thanks for the tip about the grue's last week i had the brilant idea to turn all the lights off to save on our energy bill, now ill issue each person with there own torch to keep the grues at bay.
Admin
Isn't the REAL POWER(tm) if this, that if you want to change the expression ">=14" to something like ">=17" that you can just do it in one place, the constants file. See that's just clever.
Admin
You need a DBA to update some rows ?
Admin
Sometimes, yes. Financial and governmental (note the -mental) institutions may require it. I used to prepare INSERT/UPDATE statements when working for a bank, f.e., and emailed them to the DBAs.
Admin
It's not a WTF.
Clearly, he was paid per line of code.
And, his progress was measured in lines of code produced per day.
Go Enterprisey software model! Go, go go!
Admin
Admin
Admin
Yes, yes, you are
Admin
Nope, I was right there with you.
You are in front of a small white house of cards. There is a mailbox here.
The mailbox contains _GREATER_THAN14 bug reports, and a leaflet.
Taken.
"You are now the proud owner of a Horrible Mess!"
Admin
The people in Europe who are paying them that much for their outdated, useless skills? ;-)
Admin
Sorry, no, I also caught the Zork reference ;)
Admin
What, you don't read your morning RSS feeds with a lantern just in case it gets dark?
Admin
Naaaaaaaaaaah.
public static String _ONE = "1"; public static String _TWO = Integer.toString(Integer.parseInt(_ONE) + Integer.parseInt(_ONE));
And so forth.
Admin
Admin
Seriously, am I the only one who caught the Colossal Cave /Adventure reference? I must be getting old...
Admin
Umm, around here you may have Cents attached. Salaries are "indexed" which means that they are adjusted every year according to inflation. Hence, the Cents.
Admin
What if we were playing with base 0 arrays where the 14th element in the array is actually index 13?
It would be a piece of cake to change the constant GREATER_THAN_OR_EQUAL14 to the value ">=13" and keep it all kosher.
<grins and ducks>Admin
These skills are actually so useless that most MS-programmers jumped on the .NET-train. Now there are so many VB6 (VB(5/4/3...) applications hanging around and the fewer and fewer programmers with "useless" skills" are on the market. COBOL was the fist language that had such a fate. One day .NET and Java will face the same situation (and all "up-to-date-to-the-newest-(read: most insane, crappiest)-programming-language programmers" will call those programmers "lame programmers with no technical kn0wl3d93/skillz". And then, why outdated? With .NET you cannot make more than what has been done before already (in fact, you can even less given the "security" features (try to write a sniffer in .NET). Only now, with .NET, you have to write 3 times more characters on one line (NOT code) to get the same thing done.
Admin
Admin
You are absolutely right. These wannabee-programmers created an enormous mess in over 10 years of "programming (?)" that this does not only give enormous headaches maintaining these "products" but it also assures that even in 10 more years the mess will still not be cleaned out (especially because I do not see one single company actually cleaning/correcting/redesigning their so-called applications). Hence, it's not butter and bread but Champagne and Caviar we get out of it. But yet, OTOH, my head still hurts from watching/reverse engineering/analysing/improving teh codez. As you say in France: Ye can't have the butter AND the money [the price] AND a smile from the [butter/cream] sales woman.