Busted Mug

A blog that documents solutions to the most frustrating problems that occur during development in technologies such as Java, XML, AJAX, SQL, CSS and others that make me want to throw my coffee mug against the cube wall.

Tuesday, November 28, 2006

Obvious yet useful

Every programmer needs to have some of those completely obvious and simple functions taken care of in their toy box. Here's one that I programmed 1000x before realizing I should really code it once and be done: public static String nvlb(String source, String falseCase) { if (source == null || source.equals("")) return falseCase; else return source; } Put this as a static member of your class and you'll never need to code out replacing a null or blank string to throw into some sql again. It will eliminate some keystrokes, but ranks high on the DUH factor :)

0 Comments:

Post a Comment

<< Home