Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

About patterns

 
Harish Vembu
Ranch Hand
Posts: 33
Java MySQL Database Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My two questions for the forum are given below are based on Design patterns:

1. What are Value Objects and why are they needed in Enterprise application development and their role in such apps and its significance and typical benefits. Please give me a good reference material for Value Object Design pattern. I could not find a good one on the Net.

2. As per my understanding DAO pattern are basically used to simplify data access to underlying databases in Enterprise applications where EJB's are not used. Does use of a DAO layer mean use of an DAO Pattern?. In such a case Can a DAO layer be used even for an EJB based J2EE application?.

Appreciate your help to my beginner level questions.

Thanks in Advance

Harish.V
Harish_Vembu2003@yahoo.com
 
Ajith Kallambella
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ValueObject( now called TransferObject) provides a composite view of related business data. It helps in reducing fine grained data fetch from the persistence store, and provides the client with a localized view of the business data. This is especially important in a multi-tired architecture where the datastore is normally across a network from the presentation tier( and thus the name TransferObject - a business object transferred across the wire/tier). ValueObjets are also helpful to hide the raw representation of data and provide various "views" of a business object( a.k.a Domain object ).

Your understanding of DAO is quite correct, except that you should generalize the "database" as "datastore", and extend the use of a datastore beyond just EJBs because application architectures without EJBs(Servlets, JSP and JDBC ) are not uncommon. DAOs encapsulate the nuances of data access such as datastore specific APIs( RDBMS, Flat files, XML repositories, LDAP etc) and exposes a consistent interface for the rest of the application to use.

In other words, you could expose a CustomerDAO with a method getCustomerNameForId() and provide an implementation that is specific to your datastore format. If you use an XML file for storing customers, then the implementation would use a JAXP parser. Or if you used an LDAP to store customer information, then the implementation would connect to LDAP and retrieve the details. Your implementation also handles other nuances such as connection strings, exceptions, query formatting etc. But it is all hidden withing the getCustomerNamerForId() contract and your clients need not worry when you change your datastore.

Hope that helps.
 
Masoud Kalali
Author
Ranch Hand
Posts: 531
Java Mac OS X Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Harish Vembu:
My two questions for the forum are given below are based on Design patterns:

1. What are Value Objects and why are they needed in Enterprise application development and their role in such apps and its significance and typical benefits. Please give me a good reference material for Value Object Design pattern. I could not find a good one on the Net.

we use value object to transfer data between client and backend . it called VO for sake of simplicity.
usually when a remote object need some data , data are assembeled in a DTO and sent to that remote object. sometimes data that a dto carry is more that requirement of that remote object.but we send those additional data to avoid more remote function calls
sometimes it called Data Transfer Object or simply DTO,


2. As per my understanding DAO pattern are basically used to simplify data access to underlying databases in Enterprise applications where EJB's are not used. Does use of a DAO layer mean use of an DAO Pattern?. In such a case Can a DAO layer be used even for an EJB based J2EE application?.

yes you can use DAO layer even if you use EJB for persistence purpose.
main purpose of DAO is encapsulation of data access in a separate layer
correct use of dao layer which is a composition of DTO , and DAO itself make our application independent from persistence mechanism.
for example you can switch from a jdbc backend to a hibernate one in case that you need.
[ March 15, 2006: Message edited by: Masoud Kalali ]
 
Masoud Kalali
Author
Ranch Hand
Posts: 531
Java Mac OS X Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is wonderful , both of us post a reply in same minute
looks like we both viewd the page together
it is very fun imho
 
Ajith Kallambella
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
ak pillai
author
Ranch Hand
Posts: 288
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Value Objects are coarse grained data transfer mechanism (avoiding fine grained calls), minimising network round trips.

Some of these patterns like Value Object pattern, Session Fascade etc solve particular problems in J2EE.

Problem: When a client makes a remote call to the server, there will be a process of network call and serialization of data involved for the remote invocation. If you make fine grained calls there will be performance degradation.

Solution: Avoid fine-grained method calls by creating a value object, which will help the client, make a coarse-grained call.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic