Monday, March 21, 2005

awesome code snippet :)

I read this post at the dail wtf(http://www.thedailywtf.com/). And I couldnt resist my temptation to share it with you all.... Its just awesome.
--------------------------------------------------------------------------------
-- begin Horror.java ---
/**
* All code include in this class is REAL!
*/
public class Horror {

public boolean compareObjects(Object obj1 , Object obj2) {
if (obj1.equals(obj2) == true)
return true;
else
return false;
}

public horribleBreakingLoops() {
try {
for (int i = 0; i < 100; i++) {
if (i == 98) {
// Yes, java does have 'break' to exit loops
throw new Exception();
}
}
} catch (Exception e) {}
}

public stringsHorror(String lastName) {
if (lastName.charAt(0) == new String("*").charAt(0)
|| lastName.charAt(0) == new String("%").charAt(0)) {
// here goes the code ;)
}
}

protected int myHorrorIndex = new Integer("1").intValue();

public long fearOfCastingHorror() {
return System.currentTimeMillis() + new Double(Math.random()).longValue();
//instead of return System.currentTimeMillis() + (long)Math.random();
}

/**
* Does something
*
* @return Nothing
*/
public void imTooBusyToAddJavadoc() {
/**
* The method 'imTooBusyToAddJavadoc' was written by my former subordinate.
* His code was comment-free, so I asked him to document his code with
* javadoc, which is used to build documentation of the class library.
* Obviously he added too-much javadoc ;)
* /
}

public boolean checkIsNull(Object a) {
if( !a.equals(null) ) {
/// it's really kilin' me ;)
}
}

int getHttpPort() throws IllegalArgumentException {
/// and which is the illegal argument?
}
}
-- end Horror.java ---
--------------------------------------------------------------------------------

No comments: