4 Replies Latest reply on Dec 29, 2005 4:46 PM by andrey belomutskiy

    org.jboss.mq.SpyDestination.writeDest

    andrey belomutskiy Newbie

      why is writeDest method of org.jboss.mq.SpyDestination implemented so straightforwardly? i mean - OOP principles?

      also, i'm not sure but is not it also non-efficient? i mean those endless if () else if () else if () which are usually false?

      else if (dest instanceof SpyTemporaryQueue)
      {
      ...
      }
      else if (dest instanceof SpyTemporaryTopic)
      {
      ...
      }
      else if (dest instanceof SpyQueue)
      {
      ...
      }
      else if (dest instanceof SpyTopic)
      {
      ...
      }


      should not we introduce an instance method write(ObjectOutput out) on SpyDestination? this case
      writeDest will look lik

      public static void writeDest(ObjectOutput out, Destination dest) throws IOException
      {
      if (dest == null)
      out.writeByte(NULL);
      else if (dest instanceof SpyDestination) {
      dest.write(out);
      } else {
      out.writeByte(OBJECT);
      out.writeObject(dest);
      }
      }
      i think this way is much more ellegant, and. maybe,a little more efficient