Newbie n-Tier / OO Design Questions (#2)

T

Terry Paterson

Next question,

In my front tier/client I want the user to be able to search for some
parts, they will choose some search criteria and then press a SEARCH
button, at which point the criteria should be sent to the middle tier
which will actually lookup the database and then return some results..

now - lets say the search may take some time -- 5 seconds or more for
instance..

our users are very picky about the time a search takes, and in our
current app we update the display as the results come in - i.e. it may
take 5 seconds for the search to be completed -- but the first part
may be displayed after a fraction of a second..

so - we would like to keep this functionality..

I know that when I execute a query using JDBC and the mySQL JDBC
driver the query executes in a seperate thread, and I can use a
SwingWorker to update the display as the results come in...

now -- in a 3-Tier'd design this needs a little bit of thinking about
-

Option 1:

I could write a method in the middle tier which takes the search
criteria as parameters and returns a collection of results -- but this
would presumably mean the results would not be returned until the
search is complete -- which might take 5 seconds -- not acceptable..

Option 2:

I could instantiate a new search object on the middle tier which runs
in a seperate thread, and the client/front tier could continually call
some method on the remote search object (which would block / wait
until there are more results available) to get the results as they
come in - which I think would work ?

Option 3:

I could use the Observer pattern and register my front tier/client as
an Observer to the remote search object - the search object could then
call a remote method on the client/front tier whenever new search
results were available..

For options 2 and 3 - obviously if there are 100 search results it
would be inefficient to have 100 or so messages back and forth between
the client and middle tier - so it might make more sense to use some
sort of timer to batch the search results together - i.e. the middle
tier gets the search results from the DB - if the 10 results come in
quickly (maybe in 0.25s) these are batched together - if the results
come in more slowly - every 0.5s then they are sent singularly.


do the above ideas make sense ? I guess theres now much to choose
between options 2 and 3 ? unless I'm missing something..

how about the batching results together to make better use of the
network / each method call ?

again your comments are much appreciated !


(for further detail see my previous "Newbie n-Tier / OO Design
Questions" post)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top