0 Replies Latest reply on May 8, 2008 5:48 AM by Tim Fox

    Declare variables with the interface type

    Tim Fox Master

      I've noticed quite a few places in the code where the implementation type is being used to declare variables, not the interface type, e.g.:

      ArrayList myList = new ArrayList();
      


      Yuck!, should be:

      List myList = new ArrayList();
      


      or:

      MessageImpl message = new MessageImpl(JBossTextMessage.TYPE, false, 0, System.currentTimeMillis(), (byte) 1);
      


      Should be:

      Message message = new MessageImpl(JBossTextMessage.TYPE, false, 0, System.currentTimeMillis(), (byte) 1);
      


      Please don't use the implementation type in this way, it leaks implementation details and defeats the purpose of the interface/implementation split.