Logging

It helps debugging if you write to a log file as the code is executing. Beware though that logging slows down the application, so don't log too much out. You need to determine the appropriate level of logging; most logging frameworks help by allowing you to log debug, warnings, errors etc.

When logging out the values of variables or function arguments, surround the value with square brackets, so you can see any leading or trailing spaces. It is then also clearer to see what text you can search the code for e.g. "PO query returned".

if(LOGGER.isDebugEnabled()){LOGGER.debug("PO query returned["+rows.size+"] rows for PO["+poNumber+"].);}

Checking that the LOGGER is currently configured to log at the required level before logging means that you save the overhead of creating all the String objects and concatenating them if the logger is not configured at that level.