Solved

Value List Handler Pattern

Posted on 2010-09-09
9
1,060 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
ID: 33635549
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
ID: 33635752
>>>>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
ID: 33638899
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
ID: 33643528
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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 20

Expert Comment

by:ChristoferDutz
ID: 33644303
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
ID: 33668949
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
ID: 33669757
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
ID: 33689531

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
ID: 33689863
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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…

863 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

23 Experts available now in Live!

Get 1:1 Help Now