Sometimes, I come up with situations where a single instance of a class is enough, thanks to collections. An example would be my Decoder class:
public class Decoder
{
    private static final Decoder instance = new Decoder();
    private final HashMap<Client, State> states = new HashMap<Client, State>();
    private Decoder()
    {
    }
    public Packet decode(Client client, ByteBuffer data)
    {
            return null;
    }
}
But I was thinking, why not just make it so it looks something like:
public class Decoder
{
    private static final HashMap<Client, State> states = new HashMap<Client, State>();
    public static Packet decode(Client client, ByteBuffer data)
    {
            return null;
    }
}
Both designs effectively accomplish the same thing. Is there any practical difference in the two? When would I use one over the other? Thanks.
 
     
     
    