I'm afraid, I still don't really understand what you are trying todo.
could you provide a concrete example of this?

If there's only one MyType-class, there's no need to send anything
just make it static final or skip it at all

on the other hand, if you try to group several of your B-classes by
type, it may be better implementing interfaces and then
code against these interfaces on the client-side.

On Sep 24, 6:49 pm, Lemao <yde...@gmail.com> wrote:
> The use case is dynamic dispatching of actions sent from the client to
> the server.
>
> Yes, in both cases MyType.cass will need to be created but its a
> single class, a constant overhead in JS as you pointed out.
>
> In case 1, there is A.class and any number of B.class'es in addition
> to one MyType.class and no additional MyType.class overhead in the RPC
> serialized format (i.e. sending MyType.class id/name).
>
> In case 2, there is one A.class and one MyType.class and there is an
> extra payload in the RPC serialized format.
>
> Whether you want to use one of the other depends on many factors and
> for most cases it probably doesnt matter. But if you have many
> B.class'es (large app) and the app is data intensive (many send/
> receive over the wire) the question becomes more important.
>
> My initial approach is to choose case 1. Although the JS is larger its
> a one time hit since the JS, afaik, is aggressively cached on the
> browser and I have the added benefit of not having to pay the price
> for sending the extra bytes everytime B.class, or C.class, etc is sent/
> received. I also like the fact that the code becomes more type checked
> etc.
>
> On Sep 24, 11:18 am, mars1412 <martin.trum...@24act.at> wrote:
>
> > this looks very strange - what is your use case for this?
>
> > anyway - if you really want/need this: I don't think, that example 1
> > will produce larger JS than 2, because in both cases you need to know
> > MyType.class, don't you?
>
> > On Sep 24, 3:23 pm, Lemao <yde...@gmail.com> wrote:
>
> > > Based on how JS is generated and how GWT-RPC encodes objects on the
> > > wire and serializes them, what would be a better course of action:
> > > Should I prefer a pattern of adding static members to a subclass or
> > > parameterize a class by using a member variable?
>
> > > For instance, should I prefer this:
>
> > > abstract class A{
> > >    Class getType();}
>
> > > class B extends A {
> > >    Class getType(){
> > >        return MyType.class;
> > >    }
> > > {
>
> > > OR this:
>
> > > class A {
> > >     A type;
> > >     A(Class type){
> > >        this.type = type;
> > >     }
>
> > >     Class getType(){
> > >         return type;
> > >      }
>
> > > }
>
> > > Its a compromise between larger on the wire object size and JS size. I
> > > am tempted to stick with the static approach to reduce on the wire
> > > size but wanted to double check here for any words of wisdom.
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to