Top Drawer WTF



  • Long time lurker, first time poster.  I noticed this bit of code today while trying to fix a related issue.  All this method is suppose to do is return the top most availible drawer in a dual cash drawer setup.  All the drawer ID's are just numbers (stored as strings) that tell the system the position (top most stop is position 1).  I count 2 big WTF's right off the bat, anyone see any others (other then it's Java).   

    private String getTopMostAvailibleDrawer(List<String> drawerIds) {
        String topDrawer = null;
        for (String drawerId:drawerIds){
          String prevDrawer = "";
          if (drawerId.compareTo(prevDrawer) == 1){
            topDrawer = drawerId; 
          }
          prevDrawer = drawerId;
        }
        return null;
      }



  • it always returns null and always compares against the empty string?   I assume this code wasn't actually being used....



  •  In it's own little WTF, someone fixed the null pointer and if the method returned a null they just got the first drawer off the list.  


Log in to reply