Forums Register Login

Data Access Object vs Value Object patterns

+Pie Number of slices to send: Send
Need clarification of the difference between these 2 patterns. I get the gist of why they each exist (i think), just not sure what the difference is between them. When would a developer use one approach over the other?
My current understanding is that they both abstract away the implementation details behind accessing a data entity.
Any insight would be much appreciated. In fact, I am ready to book my exam once I get the whole 'pattern' thing a little more solidly.
(MVC is the only one I have used and are familiar with)
Thanks in Advance.
Andles
+Pie Number of slices to send: Send
Data Access Object is an abstraction of the layer to access data base. They key issue is to be able to access many types of databases.
Value Object is a conglomorate of many objects that the client is interested in knowing. The key issue is to reduce the network traffic between the client and the server. Instead of making numerouse calls to get each item, when this pattern is used, the client make one (?) call to the server. The server then creates a so called "valueObject" are returns to the client. From then on, the data is already available on the client side and so we avoid the necessity to talk to the client.
So, as you see there is quite a lot of difference between these two patterns.
regds.
- madhav
+Pie Number of slices to send: Send
Here is my thought:
DAO provides a seperate layor that deals with database. Classes in this layor know how to connect to the database, how to access stored procs etc. This provides two advantages: One, if your database (or related information such as username, password, JDBC driver, url where database is located etc.) changes, all you have to do is change only one layor. All other layors such as business logic layor, presentation layor etc still work the same. Second advantage is that by seperating layors, experts of specific areas can work on different layors. For example, JDBC expert can work on Data Access layor without knowing much about biz logic or presentation layor.
For Value object, think about an Address which is composed of address1, address2, city, state and zip. If your class needs all the data in the Address object from different columns of the database, and calls getXXX methods seperately, you end up making 5 calls to database (not efficient, performance overhead). If you create a value object called Address having these 5 attributes, you may just call getAddress and get the whole object back in one DB call. Address in this case is a value object.
Go to http://theserverside.com and download a free pdf book on EJB design patterns to read detailed information on both of these design patterns.
Hope this helps
Chintan
+Pie Number of slices to send: Send
That helps a lot guys. (esp the downloadable pdf!)
Andles
+Pie Number of slices to send: Send
I have this basic doubt on Value Object.
In value object, the object is passed to the client. ( ?? )
Are we using XML here??
Lets say we have Peron Object for ex:
public class Person {
private String name;
private int age;
private String city;
/* Getters and setter for the above variables.
}
Then we have ChatUser class which has method returning the Person Object.
public class ChatUser {
public Person getPersonInfo(String id) {
//implementation
}
}
So when I need the Person object, on the client side to display the details. How exactly the things work.
When I call getPersonInfo() what happens ? will it be executed on client or server?
Naturally it will be Server. So how Value Object is implemented in this case.
Thanks for the reply.
+Pie Number of slices to send: Send

Hi,
when you call getPersonInfo() it should obviously run on server side, as the information is on server. The VO is send back as a serialized object to the client.
Hope this helps.
Regards
Durga

Originally posted by L Goundalkar:
I have this basic doubt on Value Object.
In value object, the object is passed to the client. ( ?? )
Are we using XML here??
Lets say we have Peron Object for ex:
public class Person {
private String name;
private int age;
private String city;
/* Getters and setter for the above variables.
}
Then we have ChatUser class which has method returning the Person Object.
public class ChatUser {
public Person getPersonInfo(String id) {
//implementation
}
}
So when I need the Person object, on the client side to display the details. How exactly the things work.
When I call getPersonInfo() what happens ? will it be executed on client or server?
Naturally it will be Server. So how Value Object is implemented in this case.
Thanks for the reply.

 
+Pie Number of slices to send: Send
"Go to http://theserverside.com and download a free pdf book on EJB design patterns to read detailed information on both of these design patterns. "
guys, I can't find the FREE PDF book EJB design patterns. Only the source code is available.
Can you give us a URL for it?
Thanks..
+Pie Number of slices to send: Send
hi Joe Man! i think the ejb patterns book isn't available yet.. just try to visit the site regularly... and please also let us know if it's already out... thanks!
+Pie Number of slices to send: Send
Guys,
In VO, The CLIENT is either an EJB, or a Thick client or a Web Component on a different server.
It can never be browser. Right?

Thanks.
[ May 09, 2002: Message edited by: L Goundalkar ]
[ May 09, 2002: Message edited by: L Goundalkar ]
+Pie Number of slices to send: Send
Madhav are you there.. Please clarify this.
Thanks.
Friends help you move. Good friends help you move bodies. This tiny ad will help:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 2472 times.
Similar Threads
Spring vs JSF
Abstract classes vs. interfaces
FormBean[Struts] Vs ValueObject
abstract Vs interface : usability
Camel vs Spring Integration. Part 2.
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 13:28:43.