aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes About patterns Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "About patterns" Watch "About patterns" New topic
Author

About patterns

Harish Vembu
Ranch Hand

Joined: Jul 19, 2004
Posts: 33

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


Harish
SCJP ,SCDJWS
Ajith Kallambella
Sheriff

Joined: Mar 17, 2000
Posts: 5782
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.


Open Group Certified Distinguished IT Architect. Open Group Certified Master IT Architect. Sun Certified Architect (SCEA).
Masoud Kalali
Author
Ranch Hand

Joined: Jul 08, 2004
Posts: 531

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
Software Engineer - My Weblog - GlassFish Security
Masoud Kalali
Author
Ranch Hand

Joined: Jul 08, 2004
Posts: 531

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

Joined: Mar 17, 2000
Posts: 5782
ak pillai
author
Ranch Hand

Joined: Feb 11, 2006
Posts: 288
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.


java j2ee job interview questions with answers | Learn the core concepts and the key areas
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: About patterns