Link to home
Start Free TrialLog in
Avatar of cofactor
cofactor

asked on

Value List Handler Pattern

Value List Handler pattern are an alternative to potentially inefficient EJB finders.

 Could you please explain this ?
Value List Handler pattern are used  to Improve network performance . How come it is an alternative to EJB finders ?
Avatar of ChristoferDutz
ChristoferDutz
Flag of Germany image

As far as I understood this:

Lets assume you have a search interface to query 10% of the fields of some objects persisted in a remote database. Sending a query to the remote server every time yould be time consuming and a waste of networking resources. You could now immagine that you implement a component that reads only the fields used in a query and keeps them in a local cache. Then the query could be performed in-memory on the server and only the results are fetched from the database.

This is the way I would interpret the pattern.
Avatar of cofactor
cofactor

ASKER

>>>>Lets assume you have a search interface to query 10% of the fields of some objects persisted in a remote database.

10% of the fields ?   why would you do that ? . we would just search by ID or only primary key  column  .

>>>Sending a query to the remote server every time yould be time consuming and a waste of networking resources.

I guess, you mean its the same query fired every time.

>>>>You could now immagine that you implement a component that reads only the fields used in a query and keeps them in a local cache.

local cache ? does that  implemented  component  to use external cache like OSCache ?  

>>>Then the query could be performed in-memory on the server and only the results are fetched from the database.

Here is the trouble. why do you want to keep only the query in the cache ...keep results also in the cache.  ...then we could save the database hit for fetching results ...is not ?


please clarify if I'm missing something.

Hey ... you just asked for what the pattern means ... not about the implemention details. And I have to object, it does make sense to query for some but not all fields ... the 10% were just an example. Immagine you have your Outlook Addressbook ... I doubt you qilll query for much more than firstname/lastname/email ... By the way searching for ID/Primary Key is not a search at all ... ist a simple read operation. There is no need for a pattern such as this to wrap simple reads.

As I mentioned, its used for searches in which you have to quickly find the ids of records matching certain criteria and by this drastically reducing the workload on the database and the network. I certainly agree this pattern is not allways helpfull, but thats the thing with patterns ... they don't allways match.

I use this pattern pretty much and have to admit that on one system for example, I was able to reduce the Database/Network Load to 1/50th of the initial load.
caching part is not clear . why do you want to keep  query in the cache but not the result ! ....I would prefer query and result both in the cache.

Could you please clarify this ?
Well in my example about 10% of the data is needed ... so the cache only has 10% of the total Database size. If you have enough memory, certainly it's more performant to have everything cached, but in reality your data-amount can be enormous and your memory-availability is usually limited.
in terms of code:

you  want to keep the query in the cache ?

select  *  from  dbtable  where  firstname=? and  lastname=? and email=?

you know I still don't get why this pattern is called  "Value List Handler"

see the wording  "Value"  , "List"  , "Handler"  .....how does the wording match with the  purpose ?
In OOD a ValueObejct is an object that contains properties of a "full"-object. Sometimes it aggregates properties of multiple Objects. Just think of a value object as an object that contains data for you. It is usually used together with remoting applications because it is far more cheaper to send one value object containing everything the client will need to get, instead of having the client request all separate objects independently.

Ok ... to close the circle: The ValueList Handler handles a List of ValueObject that contain everything that he needs to perform his queries.

http://java.sun.com/blueprints/corej2eepatterns/Patterns/ValueListHandler.html
http://www.precisejava.com/javaperf/j2ee/Patterns.htm#Patterns107 
This seems to me , instead of returning all the results at once . it returns results page by page whenever its requested by the client.
is not Pagination is similar to this ?
 
 
 
ASKER CERTIFIED SOLUTION
Avatar of ChristoferDutz
ChristoferDutz
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial