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

    org.jboss.mq.SpyDestination.writeDest

    arro239

      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

        • 1. Re: org.jboss.mq.SpyDestination.writeDest
          starksm64

          You need to look at how the Serializable contract is used vs this writeDest utility method. They are not the same thing that can simply be encapsulated via an instance specific writeObject.

          • 2. Re: org.jboss.mq.SpyDestination.writeDest
            arro239

            i never meant any specifict exisitng writeObject method should be used instead of exising writeDesc

            i mean pieces of code which are related to each specific class inheriting SpyDestination could be moved to the body of those classes - it is discussinble if that would make code clearer - but at least [i hope at least this is true?] that would work faster - we will replace numerous constinues 'instanceof' to one and exactly one call of method

            • 3. Re: org.jboss.mq.SpyDestination.writeDest
              timfox

               

              "arro239" wrote:
              it is discussinble if that would make code clearer - but at least [i hope at least this is true?] that would work faster - we will replace numerous constinues 'instanceof' to one and exactly one call of method


              IMO, the performance gains (if any) of this will be *utterly* insignificant compared to the cost of serialization itself and network io.

              • 4. Re: org.jboss.mq.SpyDestination.writeDest
                arro239

                 

                "timfox" wrote:
                IMO, the performance gains (if any) of this will be *utterly* insignificant compared to the cost of serialization itself and network io.


                that's 105% thue about network IO, and that's true in general [but this IS a part of serialization cost]

                my guestion was mostly about if this implementation was chosen for some reason - because for me it's very ugly. so, i was interested if this implementation is good from some point of view - and the non-OOP style is a payment for that