The Artima Developer Community
Sponsored Link

Java Buzz Forum
Can you say WTF?

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Mike Shoemaker

Posts: 158
Nickname: mikeshoe
Registered: Sep, 2004

Mike Shoemaker is senior Java developer using Ruby
Can you say WTF? Posted: Mar 30, 2005 8:50 PM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Mike Shoemaker.
Original Post: Can you say WTF?
Feed Title: Unruly Rambling (java category)
Feed URL: http://www.shoesobjects.com/blog/feed.xml?flavor=rss20&category=java
Feed Description: My thoughts on software, technology, and life in general
Latest Java Buzz Posts
Latest Java Buzz Posts by Mike Shoemaker
Latest Posts From Unruly Rambling (java category)

Advertisement

The following post was inspired by the following site: The Daily WTF

During a quick review of some legacy code today, I stumbled upon this gem of a method. I can't believe how many different ways this design, or lack thereof, gets under my skin. All comments were sprinkled in for demonstration purposes only. All javadoc that existed(none) is not shown to protect the guilty.

   1:// by the method name, would you expect the return value to be a boolean?
   2:// Also, way to pass in a Date as a string and also the format. Passing 
   3:// in a simple date would have been a bit too convenient
   4:private boolean dateDifference(String fillDate, String format) {
   5:
   6:        boolean result = false; 
   7:        try { 
   8:                Date current = new Date(); 
   9:                SimpleDateFormat sd = new SimpleDateFormat(format); 
  10:                Date filldate = sd.parse(fillDate); 
  11:                if (current.compareTo(filldate) > 0) { 
  12:                        double msdiff = (current.getTime() - filldate.getTime()); 
  13:                        // for those of you that don't know, this value is the meaning of Life, 
  14:                        // the Universe, and Everything.  Or was that 42. I forget.  
  15:                        double msd = 3888000000.00; 
  16:                        if (msdiff <= msd) { 
  17:                                result = true; 
  18:                        } 
  19:                } 
  20:        } catch (ParseException e) { 
  21:            //Excellent Handling of Exceptional cases :)    
  22:            logger.error("ParseException while getting the dateDifference " + e.getMessage());
  23:        }
  24:
  25:        return result; 
  26:}

Read: Can you say WTF?

Topic: Trim Spaces in your JSP&#39;s HTML Previous Topic   Next Topic Topic: Motivated to learn?

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use