This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
An IDE is no substitute for an Intelligent Developer.
Joined: Mar 15, 2007
Thanks for the reply. I'm working on a RESTful application, however, I don't like the solution of streaming back a string containing several other strings, and then trying to read that on the client. For my application it's more practical to return a Vector containing a dynamic number of elements of different types. I know there is a soultion, however, I am struggling a bit with its implementation.
REST has the advantage of small overhead and ease of implementation, but if you're looking at a heterogeneous collection of binary objects, it's more likely you'd either want Java serialized data or something like SOAP.
Java serialized data tends to be incompatible between different Java implementations, so it's usually not good to use with mobile devices.
SOAP can encapsulate all sorts of things, but of course it's fairly high overhead.
Yavor, I think you would be pleasently suprised about how efficient and easy REST is from a mobile developers standpoint. That said, you could expand the use of the DataInput/DataOutput streams.
Lets use a vector of strings as an example. On the server side you could 1) write the number (vector size) of strings using dos.writeInt, 2) loop through the vector writing each string with dos.writeUTF. On the client site you would 1) read the number of strings with dis.readInt, 2) loop for "the number of strings" interations reading a string each iteration with dis.readUTF.
You can use similar logic to write structured data or other complex objects, but you may find REST more extensible and benefit from its platform independence.