my dog learned polymorphism*
The moose likes Performance and the fly likes List performance- design issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Performance
Bookmark "List performance- design issue" Watch "List performance- design issue" New topic
Author

List performance- design issue

Anu satya
Ranch Hand

Joined: Mar 17, 2005
Posts: 146
Hi,
I have a requirement:
I have two Lists:
1. Student List (with subject info)
2. Subject List.(with student info)

I need to display the contents as given below:

1. All the students who are studying subject 'maths' -- search by Math
2. all the subjects studied by a student 'Jhon' -- search by Student

how do i achieve it. I need to design a solution. But wondering how to desing it.


With Regards,
Anu
Martin Vajsar
Sheriff

Joined: Aug 22, 2010
Posts: 3610
    
  60

I'd start by implementing the simplest solution - that is, iterating over the lists and picking up the items that meet the criteria. Then measure the performance. If and only if it turns out to be a bottleneck of your application, start thinking about how to improve it.
Andreas Hollmann
Greenhorn

Joined: Jan 06, 2010
Posts: 27
look at filter() method from Collections2 of google-guava library.
Andreas Hollmann
Greenhorn

Joined: Jan 06, 2010
Posts: 27
also if you want to increase the performance of your list you can use SortedList decorator of happy-library.
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11256
    
  16

Martin Vajsar wrote:I'd start by implementing the simplest solution - that is, iterating over the lists and picking up the items that meet the criteria. Then measure the performance. If and only if it turns out to be a bottleneck of your application, start thinking about how to improve it.

I agree, with one caveat...You need to have defined, measurable criteria for what is "fast enough" BEFORE you do the tests. Defining that sort of thing after you've run your tests is pointless.

It seems like all far too often, if these things aren't defined ahead of time, it doesn't matter what the results are, someone will say "That's not fast enough". So, you define the requirements FIRST, and then work to meet them.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: List performance- design issue