Comment On ISelfAware, Very Thorough, Crazy Hashmaps, and More

Seeing that I somehow neglected to publish an article yesterday, I figured today would be a great day for a big ole smorgasbord of interesting code. Enjoy! [expand full text]
« PrevPage 1 | Page 2 | Page 3 | Page 4 | Page 5 | Page 6Next »

Re: ISelfAware, Very Thorough, Crazy Hashmaps, and More

2010-09-29 10:03 • by Chris (unregistered)
This reminds me of this time I was in this place and was doing something. It did or didn't' work out that time. I had bad dreams about inserting a tape or drive that same night.

Captcha: commoveo:
BYOO - Bring your own oreos.

Re: ISelfAware, Very Thorough, Crazy Hashmaps, and More

2010-09-29 10:05 • by anon (unregistered)
323464 in reply to 323463
Chris:
This reminds me of this time I was in this place and was doing something. It did or didn't' work out that time. I had bad dreams about inserting a tape or drive that same night.

Captcha: commoveo:
BYOO - Bring your own oreos.


Wha? :|

Re: ISelfAware, Very Thorough, Crazy Hashmaps, and More

2010-09-29 10:07 • by NickR (unregistered)
From here on all my code is going to implement ISelfAware. A new project called "SkyNet" or something just came through.

Re: ISelfAware, Very Thorough, Crazy Hashmaps, and More

2010-09-29 10:08 • by CJ (unregistered)
Can someone explain the wtf with the hashmap to me?

Re: ISelfAware, Very Thorough, Crazy Hashmaps, and More

2010-09-29 10:08 • by Chris (unregistered)
323467 in reply to 323464
anon:
Chris:
This reminds me of this time I was in this place and was doing something. It did or didn't' work out that time. I had bad dreams about inserting a tape or drive that same night.

Captcha: commoveo:
BYOO - Bring your own oreos.


Wha? :|


Yeah, I don't know either. I thought it was related, but I haven't slept in 28 hours, and hurting a bit from it.

Incassum.

Re: ISelfAware, Very Thorough, Crazy Hashmaps, and More

2010-09-29 10:12 • by cie3 (unregistered)
Oh crap - we are not commenting in the correct Universe

Re: ISelfAware, Very Thorough, Crazy Hashmaps, and More

2010-09-29 10:14 • by swedish tard (unregistered)
323469 in reply to 323428
WthyrBendragon:
One:
Do we get to have a discussion about whether or not 1 is a prime number?


Well, it is only integer factorable to 1 and itself so, yes, 1 is prime.

However, random it is not.

http://en.wikipedia.org/wiki/Prime_number#Primality_of_one

No, it is not.

Re: ISelfAware, Very Thorough, Crazy Hashmaps, and More

2010-09-29 10:19 • by Bert Glanstron (unregistered)
323471 in reply to 323431
frits:

Arnold Vriezekolk writes, "one of the guys on our team likes to be thorough. Very, very thorough."

/* This program will only run if the laws of mathematics hold */
if(1 == 0)
{
fprintf("Oh crap - we are not running in the correct Universe\n");
exit(17);
}






Right. Because in your universe fprintf() doesn't need a file pointer.

You are an idiot, and should be banned from using your mommy and daddy's modem.

Re: ISelfAware, Very Thorough, Crazy Hashmaps, and More

2010-09-29 10:20 • by 00Davo
323472 in reply to 323457
Steve The Cynic:
Anonymous:
Hey there Ancient Mathematician, you might be just the person I need to help me with an ancient Roman math problem. The following sum is written in Roman numerals. Can you solve it and provide your answer also in Roman numerals?

(IV + I) - V = ?

Ah, but you forget that the things we call Roman numerals were for writing down numbers, not for performing arithmetic. One of the principal advantages of the modern versions of Arabic numerals (the 0..9 system that we use today) is that they use the same notation for writing down numbers and for doing arithmetic. The Romans used a form of abacus (note that the wire-and-bead calculators that we call abacuses are in fact NOT abacuses) when performing non-trivial arithmetic.

All that, of course, does not change the fact that there is no way to use Roman number-recording-notation to write zero.

Could one not write zero in Roman numerals like this: " "?

Re: ISelfAware, Very Thorough, Crazy Hashmaps, and More

2010-09-29 10:20 • by anonymous (unregistered)
323473 in reply to 323431
Obviously this is from an embedded system without a file system. Why would you need a file pointer there?

Re: ISelfAware, Very Thorough, Crazy Hashmaps, and More

2010-09-29 10:21 • by Anonymous (unregistered)
323474 in reply to 323466
CJ:
Can someone explain the wtf with the hashmap to me?

To be honest it's not possible to verify whether this is a WTF or not. Java has a HashMap class that is empty when instantiated, so if this were Java it would be a WTF because he is explicitly clearing an empty map. But in actuality, this isn't Java at all because it is using the .NET generics syntax (HashMap<T,T>). This is not a built-in .NET class, someone has written this from scratch and they were probably trying to replicate the Java functionality. So really, we have no idea what's going on with this home-made HashMap class. The comment says that "HashMaps are crazy" and for all we know their custom implementation IS a bit crazy.

Re: ISelfAware, Very Thorough, Crazy Hashmaps, and More

2010-09-29 10:24 • by Andy P (unregistered)
323475 in reply to 323466
CJ:
Can someone explain the wtf with the hashmap to me?


The guy had put in a "clear" statement to force a newly created HashMap to be empty.

The gag, of course, is that newly created containers (...in any sane implementation, who knows what half-assed home-baked version of HashMap this guy might have been lumbered with) are always created empty because anything else is madness. So he was (we are led to presume) doing something completely pointless, *and* adding a comment explaining it which really only highlighted his own lack of understanding.

Or so we must assume. Maybe in his codebase HashMaps really are created containing random garbage. Seems unlikely, though.

Re: ISelfAware, Very Thorough, Crazy Hashmaps, and More

2010-09-29 10:26 • by Flabbergasterisk (unregistered)
323476 in reply to 323418
Only if you implement ISelfConscious.

Re: ISelfAware, Very Thorough, Crazy Hashmaps, and More

2010-09-29 10:28 • by Larry (unregistered)
323477 in reply to 323474
Anonymous:
CJ:
Can someone explain the wtf with the hashmap to me?

To be honest it's not possible to verify whether this is a WTF or not. Java has a HashMap class that is empty when instantiated, so if this were Java it would be a WTF because he is explicitly clearing an empty map. But in actuality, this isn't Java at all because it is using the .NET generics syntax (HashMap<T,T>). This is not a built-in .NET class, someone has written this from scratch and they were probably trying to replicate the Java functionality. So really, we have no idea what's going on with this home-made HashMap class. The comment says that "HashMaps are crazy" and for all we know their custom implementation IS a bit crazy.

TRWTF is that Java 1.5 came out 6 years ago.

Re: ISelfAware, Very Thorough, Crazy Hashmaps, and More

2010-09-29 10:28 • by Kuli (unregistered)
The code with the cleared new HashMap is absolutely correct.

Probably somewhere in later code, the author implemented some GOTO functionality by changing the address register of the CPU. Then you could jump directly behind the newly created HashMap! Of course you need to clear it then, to be sure that no elements are left.

Dear bert Glanstron,

2010-09-29 10:29 • by frits
323479 in reply to 323471
Hi Honey! Did you miss me? *kisses*

Re: ISelfAware, Very Thorough, Crazy Hashmaps, and More

2010-09-29 10:30 • by Severity One
323480 in reply to 323474
Anonymous:
But in actuality, this isn't Java at all because it is using the .NET generics syntax (HashMap<T,T>).

Er, what?
Map<TransactionId, List<BillingTransaction>> workMap =

new HashMap<TransactionsId, List<BillingTransaction>>();

Unless 1 == 0, that's Java. Java has had generics since 1.5, which is already getting geriatric.

Re: ISelfAware, Very Thorough, Crazy Hashmaps, and More

2010-09-29 10:32 • by Uncle Al (unregistered)
323481 in reply to 323473
anonymous:
Obviously this is from an embedded system without a file system. Why would you need a file pointer there?


And the 1 = 0 test also clearly comes from an embedded system -- who knows what universe a user might carry the system to?

Re: ISelfAware, Very Thorough, Crazy Hashmaps, and More

2010-09-29 10:43 • by Fenris (unregistered)
323482 in reply to 323427
The Nerve:
Fixed?

<!-- <script type="text/javascript">document.write('</div>')</script>
<noscript></div></noscript> -->


Broken? now you are not putting the needed </div>

Re: ISelfAware, Very Thorough, Crazy Hashmaps, and More

2010-09-29 10:44 • by aepryus (unregistered)
public interface ISelfAware {


/**
* Useful in an MBean so that it can return a live reference to itself as a
* method call
*
* @return reference to this object
*/
public ISelfAware getSelf();
}


This exposes self for a JavaBean; allowing access to the self pointer by token. Off hand, I don't know of any other way to accomplish this directly.

In my own code, I check for the "self" token explicitly and just return the self pointer in that case instead of passing the token on to the JavaBean itself. But, this solution works also.

Re: ISelfAware, Very Thorough, Crazy Hashmaps, and More

2010-09-29 10:44 • by Anonymous (unregistered)
323484 in reply to 323480
Severity One:
Anonymous:
But in actuality, this isn't Java at all because it is using the .NET generics syntax (HashMap<T,T>).

Er, what?
Map<TransactionId, List<BillingTransaction>> workMap =

new HashMap<TransactionsId, List<BillingTransaction>>();

Unless 1 == 0, that's Java. Java has had generics since 1.5, which is already getting geriatric.

Holy shit, has it been that long since I did Java? Sorry, it was still a proposal awaiting ratification the last time I wrote anything in Java. We all know how long it takes for JSRs to go anywhere but I really had no idea it had been that long. Apologies, I should have double checked that one.

Re: ISelfAware, Very Thorough, Crazy Hashmaps, and More

2010-09-29 10:47 • by vyznev
323485 in reply to 323453
Anonymous:
(IV + I) - V = ?
Why are you mixing those newfangled chicken scratches with your proper good ol' Roman numerals?

Re: ISelfAware, Very Thorough, Crazy Hashmaps, and More

2010-09-29 10:50 • by JamesQMurphy
323486 in reply to 323475
Andy P:
CJ:
Can someone explain the wtf with the hashmap to me?


The guy had put in a "clear" statement to force a newly created HashMap to be empty.

The gag, of course, is that newly created containers (...in any sane implementation, who knows what half-assed home-baked version of HashMap this guy might have been lumbered with) are always created empty because anything else is madness. So he was (we are led to presume) doing something completely pointless, *and* adding a comment explaining it which really only highlighted his own lack of understanding.

Or so we must assume. Maybe in his codebase HashMaps really are created containing random garbage. Seems unlikely, though.


He should have put 3 calls to clear(). Once to clear out the random garbage, once to clean out the rest of the garbage, and once again for lucky.

Re: Do we get to have a discussion about whether or not 1 is a prime number?

2010-09-29 10:52 • by Nutster
323487 in reply to 323417
0 and 1 are neither composite nor prime. Non-whole numbers do not qualify either. A prime is a number with by only two integer factors: 1 and itself. A composite number is the product of several primes. 1 does not qualify for either, because 1 has only one factor, which is 1, so it not prime. Also it has no prime factors, therefore it is not composite.

0 is divisible by every number (0/x = 0, for all x | x != 0). 0/0 is handled by limits in calculus class. Therefore, 0 is not prime. That said, 0 is not composite because one of its factors is not prime, as 0 is a factor and, as just shown, 0 is not prime.

Therefore, 0 and 1 are each considered neither prime nor composite.

Re: ISelfAware, Very Thorough, Crazy Hashmaps, and More

2010-09-29 10:53 • by sep332 (unregistered)
/* This program will only run if the laws of mathematics hold */
if(1 == 0)
{
fprintf("Oh crap - we are not running in the correct Universe\n");
exit(17);
}

weird, I'm listening to a Pronobozo album right now called Zero=One=Everything !

Re: ISelfAware, Very Thorough, Crazy Hashmaps, and More

2010-09-29 10:53 • by Whatever (unregistered)
The random, prime number being set to 215 is PERFECT!

Nobody trying to crack the encryption would EVER try 215, as it's not random and it's not prime.

PS., Hey frits, maybe you could just change your sig to be the Bert Glanstron thing; that would save your secret admirer a lot of time.

Re: ISelfAware, Very Thorough, Crazy Hashmaps, and More

2010-09-29 10:53 • by Anonymous (unregistered)
323490 in reply to 323480
Severity One:
Unless 1 == 0, that's Java.

So I appreciate that Java supports generics now, as per my previous comment, but I have to take exception at the above statement which is patently false. The code provided is valid C# syntax, assuming one had written a custom class called HashMap<T,T>. So your assertion is false because 1 != 0 but it is still possible for that code to be C#.

</pendantry>

Re: Do we get to have a discussion about whether or not 1 is a prime number?

2010-09-29 10:54 • by anon (unregistered)
323491 in reply to 323487
Nutster:
0 and 1 are neither composite nor prime. Non-whole numbers do not qualify either. A prime is a number with by only two integer factors: 1 and itself. A composite number is the product of several primes. 1 does not qualify for either, because 1 has only one factor, which is 1, so it not prime. Also it has no prime factors, therefore it is not composite.

0 is divisible by every number (0/x = 0, for all x | x != 0). 0/0 is handled by limits in calculus class. Therefore, 0 is not prime. That said, 0 is not composite because one of its factors is not prime, as 0 is a factor and, as just shown, 0 is not prime.

Therefore, 0 and 1 are each considered neither prime nor composite.


*golf clap*

Re: ISelfAware, Very Thorough, Crazy Hashmaps, and More

2010-09-29 10:56 • by THG (unregistered)
323492 in reply to 323412
the article:

"I stared at this code hoping something would shout 'April Fools!'," wrote Stephen, "unfortunately, nothing of the sort happened."

public static boolean isAlphaNumeric(char c)
{
return !isLetter(c) && !isDigit(c);
}



That works ... NOT!


x OR y ≡ ¬(¬x AND ¬y)
[[ http://en.wikipedia.org/wiki/De_Morgan%27s_laws ]]


Re: ISelfAware, Very Thorough, Crazy Hashmaps, and More

2010-09-29 10:57 • by boog (unregistered)
// Do not remove the following line. HashMaps...

I always get a laugh out of comments like this. It's like the comment is just daring me to do it.

Re: ISelfAware, Very Thorough, Crazy Hashmaps, and More

2010-09-29 11:00 • by Mark (unregistered)
1) TRWTF in the first code fragment is that the submitter can't read comments. I don't know MBeans, but based on this comment I'm willing to bet that they impose some kind of proxy, and this method is used to trick the proxy into letting you bypass it. On second thought, TRWTF is that their framework assumes you might have a need to bypass a proxy...

2) 1 is not prime; look it up. 215 is neither prime nor random, but then again a lot of people say "random" when they mean "arbitrary". My guess is they needed an arbitrary prime for something obscure (like a home-brew hash table), and the value was later changed by someone who had no clue why it needed to be prime. Or maybe it didn't need to be prime any more, but it was too much work to change the constant name (since the whole point with named constants is to isolate change).

3) Bad joke != WTF. The (1 == 0) test is a developer having a laugh.

Re: ISelfAware, Very Thorough, Crazy Hashmaps, and More

2010-09-29 11:00 • by ion435 (unregistered)
wtf??? what does that mean? get me outta here!!!!!!!!

Re: ISelfAware, Very Thorough, Crazy Hashmaps, and More

2010-09-29 11:02 • by boog (unregistered)
323496 in reply to 323453
Anonymous:
Hey there Ancient Mathematician, you might be just the person I need to help me with an ancient Roman math problem. The following sum is written in Roman numerals. Can you solve it and provide your answer also in Roman numerals?

(IV + I) - V = ?

Important stuff to know. Consider the following real-world application:

Rocky V + Rocky II = ?

Re: ISelfAware, Very Thorough, Crazy Hashmaps, and More

2010-09-29 11:06 • by boog (unregistered)
323497 in reply to 323494
Mark:
3) Bad joke != WTF. The (1 == 0) test is a developer having a laugh.

I'd certainly wonder "WTF?" if I found it in production code.

Re: ISelfAware, Very Thorough, Crazy Hashmaps, and More

2010-09-29 11:12 • by DCRoss
323498 in reply to 323459
THE NUMBER ONE:
Do we get to have a discussion about whether or not I am a number?

No, you are a free man.

Re: ISelfAware, Very Thorough, Crazy Hashmaps, and More

2010-09-29 11:17 • by DCRoss
323499 in reply to 323493
boog:

I always get a laugh out of comments like this. It's like the comment is just daring me to do it.


I recently inherited a system with these lines in the crontab:
 # DO NOT uncomment this next line under penalty of death!

* * * * * /usr/local/bin/call_some_function

Some days I wonder just what happened to the last person who had to work on that server.

Re: ISelfAware, Very Thorough, Crazy Hashmaps, and More

2010-09-29 11:22 • by Steven (unregistered)
323500 in reply to 323474
Anonymous:
CJ:
Can someone explain the wtf with the hashmap to me?

To be honest it's not possible to verify whether this is a WTF or not. Java has a HashMap class that is empty when instantiated, so if this were Java it would be a WTF because he is explicitly clearing an empty map. But in actuality, this isn't Java at all because it is using the .NET generics syntax (HashMap<T,T>). This is not a built-in .NET class, someone has written this from scratch and they were probably trying to replicate the Java functionality. So really, we have no idea what's going on with this home-made HashMap class. The comment says that "HashMaps are crazy" and for all we know their custom implementation IS a bit crazy.


That's also the standard Java generics syntax. I suspect both Java and full WTFness, but cannot prove it.

Re: ISelfAware, Very Thorough, Crazy Hashmaps, and More

2010-09-29 11:23 • by nibh (unregistered)
323501 in reply to 323427
The Nerve:
Fixed?


if (&& _tblItem != null != null
&& _tblItem.getTable() != null
_tblItem.getTable().getModel())


Fail

Re: ISelfAware, Very Thorough, Crazy Hashmaps, and More

2010-09-29 11:26 • by icebrain (unregistered)
To those saying that 215 and 1 aren't random numbers: go study statistics.

A random number is "a number generated for or part of a set exhibiting statistical randomness".

Since you have no idea about what generated such number, you can't say if the numbers are random or not. It's not an intrinsic property of the number, but of where it came from.

Re: ISelfAware, Very Thorough, Crazy Hashmaps, and More

2010-09-29 11:26 • by דותן כהן (unregistered)
323503 in reply to 323412
סליחה?‏

Re: ISelfAware, Very Thorough, Crazy Hashmaps, and More

2010-09-29 11:27 • by דותן כהן (unregistered)
323504 in reply to 323412
Larry:
the article:


if (_tblItem.getTable().getModel() != null
&& _tblItem.getTable() != null
&& _tblItem != null)


TRWTF is languages that read left-to-right.


סליחה?‏

Re: ISelfAware, Very Thorough, Crazy Hashmaps, and More

2010-09-29 11:32 • by Xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx (unregistered)
323505 in reply to 323415
Uh...:
public static int RANDOM_PRIME_NUMBER = 215

Ok, I see how this might be random when he entered it, but I do not see how it is prime.

Of course it's prime. Just not in base 10, or anything else you might reasonably expect. (Try 6, or 36).

Re: ISelfAware, Very Thorough, Crazy Hashmaps, and More

2010-09-29 11:34 • by amischiefr
323506 in reply to 323418
WthyrBendragon:
I keep thinking that that getSelf() method should be Private. After all, wouldn't you want to be private while doing some sort of self exam?

Hell no, I like an audience!

Re: ISelfAware, Very Thorough, Crazy Hashmaps, and More

2010-09-29 11:34 • by Caeruleus (unregistered)
323507 in reply to 323453
Anonymous:

Hey there Ancient Mathematician, you might be just the person I need to help me with an ancient Roman math problem. The following sum is written in Roman numerals. Can you solve it and provide your answer also in Roman numerals?

(IV + I) - V = ?


The answer is "II".

In ancient Roman numerals, the value is the sum of the digits. "IV" = 1 + 5. The representation for 4 was "IIII"; the convention of writing "IV" did not come until the middle ages.

On the other hand, you want to know how to represent zero, and the answer is "NULLUM" or "NIL". ( Ancient Romans did not have lower case letters. )

Re: ISelfAware, Very Thorough, Crazy Hashmaps, and More

2010-09-29 11:34 • by ted (unregistered)
323508 in reply to 323497
boog:
Mark:
3) Bad joke != WTF. The (1 == 0) test is a developer having a laugh.

I'd certainly wonder "WTF?" if I found it in production code.


Yea, but surely any optimizing compiler would remove the code at compile time?

Re: ISelfAware, Very Thorough, Crazy Hashmaps, and More

2010-09-29 11:53 • by ShatteredArm (unregistered)
if (_tblItem.getTable().getModel() != null 

&& _tblItem.getTable() != null
&& _tblItem != null)


I had a coworker do this. He was absolutely nonplussed as to why his code was throwing object reference exceptions when the field wasn't even required.

Re: ISelfAware, Very Thorough, Crazy Hashmaps, and More

2010-09-29 11:59 • by Bob (unregistered)
323510 in reply to 323504
דותן כהן:
Larry:
the article:


if (_tblItem.getTable().getModel() != null
&& _tblItem.getTable() != null
&& _tblItem != null)


TRWTF is languages that read left-to-right.


סליחה?‏

Welcome to the 21st century. News Flash: Judaism is no longer funny.

Re: ISelfAware, Very Thorough, Crazy Hashmaps, and More

2010-09-29 12:03 • by Hitler (unregistered)
323511 in reply to 323510
Bob:
דותן כהן:
Larry:
the article:


if (_tblItem.getTable().getModel() != null
&& _tblItem.getTable() != null
&& _tblItem != null)


TRWTF is languages that read left-to-right.


סליחה?‏

Welcome to the 21st century. News Flash: Judaism is no longer funny.

Really? Because it was hilarious in the 20th century!

Re: ISelfAware, Very Thorough, Crazy Hashmaps, and More

2010-09-29 12:03 • by shimon
Sup dawg, I heard you like references, so we've put a reference in your reference so you can get self while you have self!

Re: ISelfAware, Very Thorough, Crazy Hashmaps, and More

2010-09-29 12:04 • by The Judge (unregistered)
323513 in reply to 323511
Hitler:
Bob:
דותן כהן:
Larry:
the article:


if (_tblItem.getTable().getModel() != null
&& _tblItem.getTable() != null
&& _tblItem != null)


TRWTF is languages that read left-to-right.


סליחה?‏

Welcome to the 21st century. News Flash: Judaism is no longer funny.

Really? Because it was hilarious in the 20th century!

I DEMAND THAT THIS IMMEDIATELY BE MADE A FEATURED COMMENT
« PrevPage 1 | Page 2 | Page 3 | Page 4 | Page 5 | Page 6Next »

Add Comment