Question: Similar to [this question](https://stackoverflow.com/questions/233030/worst-php-practice-found-in-your-experience)...

What are the worst practices you actually found in Java code?

Mine are:

* using instance variables in servlets (it's not just bad practice but bug, actually)
* using Collection implementations like HashMap, and not using the appropriate interfaces
* using seemingly cryptic class names like SmsMaker (SmsFactory) or CommEnvironment (CommunicationContext)

Answer: 
In File I/O: incorrect use of try-catch block.

```
try {
   /* open file */
}
catch(Exception e) {
  e.printStackTrace();
}

try {
   /* read file content */
}
catch (Exception e) {
  e.printStackTrace();
}

try {
   /* close the file */
}
catch (Exception e) {
  e.printStackTrace();
}

```
A mistake made by junior programmers: unnecessarily using member variables instead of local variables.

A Java EE example:

Starting threads in servlets or EJBs (for example to start asynchronous processing tasks).

This breaks the scalability of your Java EE app. You're not supposed to mess with threading in Java EE components, because the app server is supposed to manage that for you.

We refactored this by having the servlet put a message on a JMS queue and writing a message-driven bean to handle the asynchronous processing task.