tags:

views:

67

answers:

1

I see that there are two ways of transferring objects from server to client

  1. Use the same domain object (Contact.java) as used in the service layer. (I do not use hibernate)

  2. Use the HashMap to send the domain object field values in the form of Map with the help of BeanUtilsBean class. For multiple objects, use the List>. Similary, use the Map to submit form values from client to server

Is there any performance advantage for option 1 over 2?.

Is there a way to hide the classname/package name that is sent to the browser if we use option 1?.

thanks!.

+1  A: 

You have to understand that whatever option you choose, it will need to get converted to JavaScript (+ some wrappers, etc.) - this stuff takes more time and space/bandwidth (note: I haven't done any benchmarks, this is just a [reasonable] conclusion I came up with ;)) than, say, JSON. But if you used JSON, you have to recreate the object on the server side, os it's not a silver bullet. In the end, it all depends how much performance is of an issue to you - for more insight, see this question.

I'd go with option 1: just leave it to the GWT team to pack your domain objects and transfer them between client and server. In the future (GWT 2.1), we'll have some really nice things, including a more lightweight transfer protocol - see this years presentation from Google I/O on architecting GWT apps - it's something worth keeping in mind.

PS: It's always good to do benchmarks yourself in this kind of situations - your configuration, the type of objects, etc. might yield some different results than expected.

Igor Klimer