Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Large apps in GWT: one module, or several?

Tags:

gwt

In order to provide nice URLs between parts of our app we split everything up into several modules which are compiled independently. For example, there is a "manager" portion and an "editor" portion. The editor launches in a new window. By doing this we can link to the editor directly:

/com.example.EditorApp?id=1

The EditorApp module just gets the value for id and loads up the document.

The problem with this is ALL of the code which is common between the two modules is duplicated in the output. This includes any static content (graphics), stylesheets, etc.

And another problem is the compile time to generate JavaScript is nearly double because we have some complex code shared between both modules which has to be processed twice.

Has anyone dealt with this? I'm considering scrapping the separate modules and merging it all back into one compile target. The only drawback is the URLs between our "apps" become something like:

/com.example.MainApp?mode=editor&id=1

Every window loads the main module, checks the value of the mode parameter, and and calls the the appropriate module init code.

like image 734
Mark Renouf Avatar asked Dec 01 '08 21:12

Mark Renouf


1 Answers

I have built a few very large applications in GWT, and I find it best to split things up into modules, and move the common code into it's own area, like you've done. The reason in our case was simple, we had some parts of our application that were very different to the rest, so it made sense from a compile size point of view. Our application compiled down to 300kb for the main section, and about 25-40kb for other sections. Had we just put them all in one the user would have been left with a 600kb download, which for us was not acceptable.

It also makes more sense from a design and re-usability point of view to seperate things out as much as possible, as we have since re-used a lot of modules that we built on this project.

Compile time is not something you should generally worry about, because you can actually make it faster if you have seperate modules. We use ant to build our project, and we set it to only compile the GWT that has changed, and during development to only build for one browser, typical compile times on our project are 20 seconds, and we have a lot of code. You can see and example of this here.

One other minor thing: I assume you know that you don't have to use the default GWT paths that it generates? So instead of com.MyPackage.Package you could just put it into a folder with a nice name like 'ui' or something. Once compiled GWT doesn't care where you put it, and is not sensitive to path changes, because it all runs from the same directory.

like image 176
rustyshelf Avatar answered Sep 19 '22 21:09

rustyshelf