| « The Horrible and Stupid System | Souvenir Potpourri: Anything Will Do » |
"While digging through some database code in our system," Paul L wrote in, "I noticed an interesting pattern emerge. Whenever a boolean value within a SQL result was checked, it would look something like this..."
if (result != null && result.toUpperCase.equals(OurBoolean.TRUE))
{
...
}
"And although OurBoolean lacks a FILE_NOT_FOUND parameter, it does optimize for performance and memory usage through lazy list initialization."
package com.initrodeglobal.db.utils;
import java.util.List;
import java.util.ArrayList;
public class OurBoolean {
public static final String TRUE = "TRUE";
public static final String FALSE = "FALSE";
private static List list = null;
public static List getList() {
if(list == null) {
list = new ArrayList();
list.add(TRUE);
list.add(FALSE);
}
return list;
}
}
What in the world makes you think that the default allocation of <10> is anywhere near enough to store a boolean value? 1 TRUE 2 "TRUE" 3 "True" 4 "true" 5 FALSE 6 "FALSE" 7 "False" 8 "false" 9 true 10 false 11 Boolean.TRUE 12 Boolean.FALSE 13 "Y" 14 "Yes" 15 "YES" 16 "y" 17 "yes" 18 "N" 19 "No" 20 "NO" 21 "n" 22 FileNotFound |
| « The Horrible and Stupid System | Souvenir Potpourri: Anything Will Do » |