• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

List or Array of DataInfo objects

 
Aruna Raghavan
Ranch Hand
Posts: 194
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Just curious why most people are using Array of DataInfo objects rather than a List to pass search results from the server to the client? Is this due to performance reasons?
Aruna.
 
Rajesh So
Ranch Hand
Posts: 149
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using a List, which contains all the DataInfo objects. Reason is that it gives an encapsulation of the package you are sending to someone.
Is the reasoning right?
 
Aruna Raghavan
Ranch Hand
Posts: 194
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, using a List is nice because you don't have to worry about predefining its size. I don't like to use arrays if I can help it. However, I am not sure if there is any performance advantage of using an Array. Also, I haven't tested sending a List using RMI yet, so I was wondering if this could cause problems with RMI.
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As long as you use a serializable List implementation (for example ArrayList) you're fine with RMI. Whether to use a List or an array is a matter of taste, and fit with the existing API -- note that the existing Data API likes to use arrays.
- Peter
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Another thought. The reason some prefer arrays over Lists is that arrays are typed (I can't wait for generics in J2SE 1.5, which would allow you to return a List<DataInfo> . In many cases you end up using a List to build the results and converting the list to an array in the return statement.
- Peter
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic