Sri: Yes, performance is an issue - but not a very big one, I think.
Think about it: how many messages do you have? Maybe a hundred or so?
How often do you need to load the messages? Usually _once_, when
initializing a widget.
I think neither the size (about 3-5 bytes per call + constant size),
nor the speed gain (0.03-0.2 msecs per call in _hosted mode_)
compensate the fact that I got rid of some unnecessary Java code :)
Yes, it's nice to be on the edge and optimize everything - but writing
webapps in GWT (Java) instead of JavaScript is not optimal in the
first place. I believe it's goal was to provide a developer-friendly
way of creating ajax apps, and I see this ideal seriously damaged by
the fact that the development cycle is based on how the GWT internals
work, instead of providing a framework first and optimizing
compilation after that.
Denis: I thought about that myself, and I'm planning the feature. As I
see now, one possible way of creating multiple bundles is like how the
original Messages works - you would have to create an (empty)
interface extending some base interface. This is because the GWT
Generator can only work with classes and methods (and so without a
type it has no idea where to ge the bundles from). It would be nice,
because one would see the bundle and the class side by side - but
would break the original idea of throwing out unnecessary classes :)
Another idea is to provide the bundle names in an extendable property
in the .gwt.xml - this is probably the cleaner solution and I think
I'll go with that.
The reason I didn't implement it in the first place was that we only
had monolithic GWT applications so far. What is a multi-module GWT app
good for? I mean how do you use the modules? Is there any
communication between them, or are they like portlets?
Geri
On nov. 29, 18:09, Sripathi Krishnan <
sripathi.krish...@gmail.com>
wrote:
> There is a reason why a lookup method doesn't exist - performance.
>
> With methods like getBasketballImage() and getFootballImage(), the compiler
> knows which images are actually used. So, if you have 10 sports but only end
> up using two - the compiler can automatically discard the other eight. With
> getSportImage(sportId), the compiler has no way of knowing what ids you will
> end up passing at runtime - so it will have to retain all 10 images.
>
> With strings and messages, the compiler inlines the strings. This means it
> is as good as hard coding it. Simply said,
> new Label(messages.getBasketballText());
> becomes
> new Label("I like basketball");
>
> There are times when you absolutely need dynamic behaviour. For those times,
> use ConstantsWithLookup. With images, manually create a map, or use the
> generator that was mentioned in this thread. But that should be an exception
> rather than the norm.
>
> --Sri
>
> 2009/11/28 denis56 <
denis.ergashb...@gmail.com>
> >
google-web-tool...@googlegroups.com<
google-web-toolkit%2Bunsu...@googlegroups.com>
> > .