Tuesday, June 3, 2014

Re: Best practices for reducing generated RPC Serialization code?

Hi Jens,

Yes it is true that all commandrequest/response objects will have serializers generated, but that is exactly what I want. You could implement some segregation by having multiple request/response base types and different command processors, but in my case that would be too much work for little gain.

I cut down on the amount of classes by having a generic response type and I am grouping handlers in one class when they are of a related business domain. The grouping happens with a base interface that uses the visitor pattern. That way I can easily dispatch to the right method in the actual Handler class. There really is not much friction when adding new commands to my system, eclipse actually guides you in creating the request, add a visitor method etc and you don't need to maintain both sync, async interfaces and a servlet (and potentially web.xml updates).

To forward a request to the right handler I am using an annotation and Guice on the server side. All I need is one binding in GIN which maps to a Handler that can handle a group of related functionalities.

I also added lots of useful things like automatic error handling, authentication with an external Identity Provider ... the business code is completely oblivious to these things. Instead of using an AsyncCallback I am using my own implementation of a Promise. This makes writing testing code even simpler than when faking an AsyncCallback and it will make my life so much easier when I can use Java 8.

David



On Mon, Jun 2, 2014 at 11:12 PM, Jens <jens.nehlmeier@gmail.com> wrote:
I'm also using a command pattern iso RPC directly, that makes my exposure to GWT specifics minimal and I can bypass the RPC part for automated tests. This way I add extra features like bulking, security, caching, etc.

However if you use command pattern GWT generates serializers for each command & command result class. If you would call direct RPC methods instead of transferring commands you would save these serializers. I am also using command pattern in a larger app and I am still not sure if I like it or not. It's cool to have a central place to implement RPC relevant features but all these command/result classes are annoying.

-- J.

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment