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!

"I found the following code in our core architecture library," Steven writes, "I could make a smart-ass comment about needing a reference to get a reference, but I think the code speaks for itself."

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();


"I've been thinking about looking for a new position for a little while now," wrote Daniel, "but after finding this I'm thinking about a new career!"

if(completed == 1)
   if(startdate[1] != 2)
      month = startdate[2];
      month = startdate[2];
   month = startdate[2];


"This is one of our developer's misguided attempts to prevent a null pointer exception," writes Yamee.

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


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");


"This is in our production code," notes Joseph Daigle, "I can only hope they rolled a die to ensure this was actually random."

public static int RANDOM_PRIME_NUMBER = 215;


"I stumbled upon this while clearing up an Excel Automation project," Veggen Skrikk writes, "I wonder who's that lucky fellow!"

/*3 times because if we have filter on some column - 
  clean only that data, and after that cleans everything 
  else (2.), and the 3. is for lucky :) */


Phil writes, "the 2.2 release of the Android SDK pays homage to WTF moments with an actual API change to the log code."

// What a Terrible Failure: Report a condition that should never happen. 
Log::static int wtf(String tag, String msg)


"I found this snippet in the middle of a large class written by a colleague of mine," Matt writes, "I think the comment and the snippet itself sum up my experiences with this particular developer perfectly."

Map<TransactionId, List<BillingTransaction>> workMap
    = new HashMap<TransactionsId, List<BillingTransaction>>();

// Do not remove the following line. HashMaps are crazy and point 
// to old reference data even if they were instantiated fresh!


"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);


"I found this while going through a (thankfully, long gone) colleague's code," Craig wrote, "there were atleast four of these in the code."

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