MVC + Command Pattern + Code Splitting?

163 views
Skip to first unread message

gktcs

unread,
Aug 1, 2011, 10:28:07 AM8/1/11
to Google Web Toolkit
Has anyone been able to get "complete" code splitting working with gwt-
dispatch or similar command pattern implementation?

We've got a rather large MVC-based application, and our code splitting
is done at the Controller level. The code splitting works great--
neither the Controller nor the View will be loaded unless the
associated module has been explicitly requested. We use gwt-dispatch
(with SecureDispatchAsync) to provide our communication with the
server. Everything works great with gwt-dispatch, except that *all*
of our Request (Action) and Result objects are compiled into the
initial download, instead of being included in the split point which
contains the associated Controller and View.

We're using SecureDispatchAsync in the startup module to load some
basic startup information, but all of the other Request/Result pairs
are isolated to their corresponding Controller. The GWT SOYC report
shows that all of the Request and Result objects are being included in
the initial download. Given the large-ish number of Action/Result
objects we have, this is adding significant bulk to our initial
application download size.

I've read around and asked on the gwt-dispatch group and it seems like
no one has had to use code splitting and the command pattern; so far,
the only answers I've been able to find were (a) had to get rid of gwt-
dispatch/command pattern, (b) just accept the increased size, or (c)
it could be related to this issue: http://code.google.com/p/google-web-toolkit/issues/detail?id=2374.

Just curious as to what others are doing, or if someone has found a
way around this problem

Thanks

Juan Pablo Gardella

unread,
Aug 2, 2011, 8:52:03 AM8/2/11
to google-we...@googlegroups.com
+1

2011/8/1 gktcs <tdots...@gmail.com>

--
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-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.


Jens

unread,
Aug 2, 2011, 9:22:08 AM8/2/11
to google-we...@googlegroups.com
I can't really remember gwt-dispatch as I use a custom command pattern and no framework..but in general the only thing you can do is to provide multiple dispatch services, e.g. one per application module. Each dispatch service would then use a different command base interface.

So if you have two app modules "mod1", "mod2" then you would have

- Mod1DispatchService(Mod1Command command, ...)
- Mod2DispatchServce(Mod2Command command, ...)

Inside mod1 you will always use Mod1DispatchService and commands that extend Mod1Command and in mod2 the mod2 counter parts. No cross references! So instead of one global generic dispatch service you will have several more specific ones. 

If you can't do that with gwt-dispatch then well..you have to live with the code size or get rid of gwt-dispatch.

Also make sure you do not use List or any generic interfaces inside your commands unless you really need to. This will also increase your code size as GWT will generate serializer classes for all implementations of List. 
BTW these generated serializer classes are the problem why you cant code split like you want to. The generated dispatch service contains a map with all types (all implementations of your base command interface) used in your service methods and their corresponding serializer classes. And because of that map every command will be in the initial download.

-- J.

Gal Dolber

unread,
Aug 2, 2011, 9:24:00 AM8/2/11
to google-we...@googlegroups.com
same problem here +1

I have been thinking a lot about this and I don't think there is a simple solution.
A custom rpc generator with node detection that load all the node's dependencies inside a GWT.runAsync is the only thing I could think of, but I didn't try to implement it yet.

In the gwt-dispatch case(or any rpc-command implementation), every action is a node, so the first time we execute each action we load and register the action and response dependencies.
--
Guit: Elegant, beautiful, modular and *production ready* gwt applications.

http://code.google.com/p/guit/




Gabriel

unread,
Aug 3, 2011, 9:23:55 AM8/3/11
to Google Web Toolkit
Reply all
Reply to author
Forward
0 new messages