• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Data Access Object vs Value Object patterns

 
Andles Jurgen
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Madhav Lakkapragada
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Chintan Rajyaguru
Ranch Hand
Posts: 341
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Andles Jurgen
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That helps a lot guys. (esp the downloadable pdf!)
Andles
 
L Goundalkar
Ranch Hand
Posts: 395
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Durga Penmatsa
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.
 
Joe Man
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"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..
 
Paul Michael
Ranch Hand
Posts: 697
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
L Goundalkar
Ranch Hand
Posts: 395
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
L Goundalkar
Ranch Hand
Posts: 395
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Madhav are you there.. Please clarify this.
Thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic