Hi,
I know Singular is in a prototype state, but I’m wondering about one thing. The definition of the model is done using fields. But then the controller is using a class which is apparently generated during GWT build and is providing access via getters and setters instead of fields.
I think it is introducing some problems, mostly due to no link between the declared model and generated model.
Firstly, you cannot use the model until GWT generates it. It is very well visible on the GWT.create presentation, where there are errors in the workspace until the compilation finishes; and there are generated sources added to project source paths. This also applies to any changes to the model, like adding a field.
Secondly, refactoring is a problem. IDE refactor tools won’t see connection between fields in declared model and those in generated class. So, every time you change model (rename a field), you will need to manually change all usages of the corresponding access methods.
Solution
My suggestion would be that the model is declared as an interface with setters and getters. Then the GWT generates implementation of that interface and this is injected into the controller. But controllers just works with the declared model interface and knows nothing about generated objects.
Obviously, the declared model is less readable this way (will there be properties in Java some day?), but the advantage is that there are proper references between model and its usage, so that tools can see usages properly. Also, the whole code is self-contained and error-free even without the generated classes. We could then also think of adding JsInterop annotations on it, so then we could also pass the model to JavaScript if needed.
What do you think?
Cheers,
Marcin