When using GWT-RPC, it pays to be as specific as possible. The reason is
that in order to support polymorphism, the GWT-RPC compiler creates a custom
serializer and deserializer for each subclass of your RPC return and
argument types. This adds to compile time and the size of your application.
Object is blacklisted for obvious reasons. I think Serializable is, too, but
you don't want to do that, anyway, as there are an awful lot of classes that
implement Serializable.

/dmc

On Fri, Mar 18, 2011 at 3:37 PM, Ben Imp <[email protected]> wrote:

> If I saw #2 in any code I was responsible for I would hunt down and
> beat the person who wrote it.  With a rusty spork.
>
> I may be slightly resentful of having bad code dumped on me.
> Possibly...
>
> Defining your methods return type is good practice.  I recommend
> creating a result object to return for the same reason I recommend not
> returning type Object on every method.  Its good documentation, and,
> in my mind, makes for a more stable and healthy application.  You'll
> probably forget what index #3 in your array is a few months down the
> line anyway, and if you want to try and remove a result from the array
> you will have a hard time tracking down where it gets used.
>
> All remote methods in the GWT application I maintain use a result
> object.  I have found it to be well worth the extra bit of code and
> effort in order to gain the benefits.
>
> -Ben
>
> On Mar 18, 12:50 pm, "ss.require" <[email protected]> wrote:
> > I want to create an RPC-method that returns 3 java-objects that can
> > have different types. These types are always Serializable. So I have 2
> > possible approaches:
> > 1)Create a new class "SomeClass" with properties of these types and
> > return this object: public SomeClass someMethod()......
> > 2)Retrun Serializable array:  public Serializable[] someMethod()......
> >
> > I prefer the 2) approache, cause I don't like to create new class just
> > to pass objects through RPC. Is it correct to do that from the
> > perspective of GWT? Or I should create a new class every time when I
> > want to pass a cortège of objects of different types?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google Web Toolkit" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/google-web-toolkit?hl=en.
>
>


-- 
David Chandler
Developer Programs Engineer, Google Web Toolkit
w: http://code.google.com/
b: http://googlewebtoolkit.blogspot.com/
t: @googledevtools

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to