• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

List or Array of DataInfo objects

 
Ranch Hand
Posts: 194
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 149
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
author
Posts: 3252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 3252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic