Solved

Value List Handler Pattern

Posted on 2010-09-09
9
1,041 Views
Last Modified: 2013-11-24
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 ?
0
Comment
Question by:cofactor
  • 5
  • 4
9 Comments
 
LVL 20

Expert Comment

by:ChristoferDutz
Comment Utility
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.
0
 

Author Comment

by:cofactor
Comment Utility
>>>>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.

0
 
LVL 20

Expert Comment

by:ChristoferDutz
Comment Utility
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.
0
 

Author Comment

by:cofactor
Comment Utility
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 ?
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 20

Expert Comment

by:ChristoferDutz
Comment Utility
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.
0
 

Author Comment

by:cofactor
Comment Utility
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 ?
0
 
LVL 20

Expert Comment

by:ChristoferDutz
Comment Utility
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.
0
 

Author Comment

by:cofactor
Comment Utility

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 ?
 
 
 
0
 
LVL 20

Accepted Solution

by:
ChristoferDutz earned 150 total points
Comment Utility
Well I would say that pagination is one instance of the search. The problem with pagination comes with ordering of the elements. If your result is unordered, pagination would be simple. With ordering you have to know all results in order to return only the firs 10 (respecting the requested order). Most of the results are thrown away afterwards.

Now immagine your value object cache is filled with all the stuff that you need to perform the sorting/filtering and so on. Using this pattern you are able to determin which elements you acutally have to load without having to load all elements in the first place.
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

I had a project requirement for a displaying a user workbench .This workbench would consist multiple data grids .In each grid the user will be able to see a large number of data. These data grids should allow the user to 1. Sort 2. Export the …
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
The viewer will learn how to implement Singleton Design Pattern in Java.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now