Anywhere you find yourself re-writing the same code more than three times, you would likely benefit from a generator.
Linkers are only useful if you need to translate java source into artifacts other than the embedded js. For gadgets and files that require xml configurations, it may be more work up front to write a generator + linker combo, but it will save piles of frustration because your config file comes from your source code, rather than being edited by hand. Currently, I'm doing a lot of work with creating my own cross-platform dependency injection framework (by implementing java.util.ServiceLoader for gwt). The easy part was getting the generated javascript to work; the hard part was getting dev mode to work correctly, since it does not honor super-source overrides. I prefer to work with interfaces and annotations as much as possible, and generators really help fill the gap without having to manually bind an interface to a factory or, even worse, just hardcoding an implementation. My next task for code generation will be to subclass java.lang.Thread and have it export a generated artifact to a web worker. Rather than manually export multiple modules for the web workers and test them with trial, error and lots of recompiles, I'm just going to write a generator which acts as a generic ThreadFactory, spits out a controller interface that will speak through to the web worker (or js object if web worker unavailable), and link the actual worker code into a separate js compile. This way, I can get the boilerplate right exactly once, and then reuse that boilerplate by calling GWT.create(GwtThread.class) any time I want to offload tasks to a web worker. On Monday, September 17, 2012 3:11:38 PM UTC-6, Ed wrote: > > Just curious: where do you use your linker and generators for? > (I always tried to avoid them as much as possible, don't like hem). > > Op maandag 17 september 2012 20:06:10 UTC+2 schreef Ajax het volgende: >> >> Not everything can be tested with unit tests. >> >> I write a lot of generator + linker code, so, by necessity, I must use >> GWTTestCase, as I am testing the compilation process. >> >> If your tests don't involve the gwt generator, then definitely don't >> incur the overhead of GWTTestCase, >> but if you are working in the generator layer, or if you want to test a >> functional gui in the browser, then you should use GWTTestCase. >> >> It might be possible with selenium to achieve the in-browser tests, but >> you will likely need to run the gwt compile anyway, >> so you might as well just use the testing suite provided. =} >> >> On Sunday, September 16, 2012 3:49:38 PM UTC-6, Ed wrote: >>> >>> @ tanteanni : >>> Easiest solution: don't use GWTTestCase... It simple doesn't work well >>> and if you have it working, it's hard to maintain... >>> >>> Try to do everything through unit testing... >>> Nowedays I can test almost everything through unit tests, and works >>> well. Google around for "awesome testing with IsWidget", >>> if I remember correctly, and you find some forum posts of me that might >>> help you in the correct direction... >>> >>> - Ed >>> >> -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/Gmv3jx9lTTkJ. 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.
