Lim,

In a nutshell, combined with the DAO pattern, they keep your data access
logic outside of your web logic. 

This means that you can make changes to how you access you data without
constantly modifying your presentation and control logic

In my own humble experience you can get away without this for simple
projects, but once your projects gets complex, these will really help you
organise and simplify your data access logic

cheers
Colin.W

http://as400blog.blogspot.com
 
Extension   5800
Direct dial   0870 429 5800


-----Original Message-----
From: Lim Hock-Chai [mailto:Lim.Hock-Chai@xxxxxxxxxxxxxxx] 
Sent: 04 January 2005 16:20
To: Java Programming on and around the iSeries / AS400
Subject: RE: DAO design pattern


Please note that I'm a beginner java programmer.  So, here I go.

I'm assuming that JT400SomeObjectDAO needs to implement SomeObjectDAO.  Is
that correct?

Still not sure what SomeObjectDAOFactory for yet.  


Here is a stupid beginner question:
Why do I need SomeObjectDAO interface if JT400SomeObjectDAO is probably the
only class that will implement SomeObjectDAO? 

Can you or Collin give me a short info on how Ibatis or Hibernate help
development cycle? 

-----Original Message-----
From: java400-l-bounces@xxxxxxxxxxxx
[mailto:java400-l-bounces@xxxxxxxxxxxx]On Behalf Of
Niall.Smart@xxxxxxxxxxxxxxx
Sent: Tuesday, January 04, 2005 4:59 AM
To: Java Programming on and around the iSeries / AS400
Cc: java400-l-bounces+niall.smart=friendsfirst.ie@xxxxxxxxxxxx; Java
Programming on and around the iSeries / AS400
Subject: Re: DAO design pattern


Lim

Create an interface which defines the data related operations 
independantly of any particular representation/access method (i.e., 
file/JDBC, etc)

public interface SomeObjectDAO {

        public void create(SomeObject object)
                throws DAOException;

        public void delete(Integer objectID)
                throws DAOException;

        public SomeObject findByID(Integer objectID)
                throws DAOException;

        public List findByKeyword(String keyword)
                throws DAOException;
}

Then write an implementation of this interface using the JT/400 API:

public class JT400SomeObjectDAO {

        public SomeObject findByID(Integer objectID) {
 
                AS400File file = ....

                SomeObject someObject = new someObject();

                someObject.setFoo(file.readInteger());
 
                return someObject;
        }

        // ...
}

And finally write a factory to create instances of SomeObjectDAO:

public class SomeObjectDAOFactory {

        private static instance = new SomeObjectDAOFactory();

        public static SomeObjectDAOFactory getInstance() {
                return instance;
        }

        public SomeObjectDAO newInstance() {
                return new JT400SomeObjectDAO();
        }

}

You don't gave to use checked exceptions.   A framework like spring can 
obviate the need for trivial factory objects.




"Lim Hock-Chai" <Lim.Hock-Chai@xxxxxxxxxxxxxxx> 
Sent by: java400-l-bounces+niall.smart=friendsfirst.ie@xxxxxxxxxxxx
03/01/2005 18:40
Please respond to
Java Programming on and around the iSeries / AS400 
<java400-l@xxxxxxxxxxxx>


To
"Java Programming on and around the iSeries / AS400" 
<java400-l@xxxxxxxxxxxx>
cc

Subject
DAO design pattern






Anybody has a good example on how should I design my web application for 
any file access related transaction?
 
I'm using struts to create this web apps.  I just wonder when I'm in the 
Action Form and I need to do some edit/insert/update on a record in a 
file, what is the correct way to design this.  I've read some article 
about DAO design pattern.  If this is a good approach, can anybody provide 
some example.  (Note: I'm using Tomcat4.1 and plan to use DBCP for 
connection pooling.) 
 
thanks.
-- 
This is the Java Programming on and around the iSeries / AS400 (JAVA400-L) 
mailing list
To post a message email: JAVA400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/java400-l
or email: JAVA400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/java400-l.




The information contained in this e-mail is confidential and may be
privileged. It  is intended only for the addressee(s) stated above. If you
are not an addressee, any use, dissemination, distribution, publication, or
copying of the information contained in this e-mail is strictly prohibited.

Friends First Life Assurance Company Ltd is regulated
by the Irish Financial Services Regulatory Authority. 

If you have received this e-mail in error, please immediately notify us by
telephone at 353-1-6610600 or e-mail Helpdesk@xxxxxxxxxxxxxxx and delete the
e-mail from your system.

Thank you for your co-operation.
Friends First  Group, Cherrywood Business Park , Loughlinstown Dublin 18.


-- 
This is the Java Programming on and around the iSeries / AS400 (JAVA400-L)
mailing list To post a message email: JAVA400-L@xxxxxxxxxxxx To subscribe,
unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/java400-l
or email: JAVA400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/java400-l.

This e-mail has been sent by a company of Bertram Group Ltd, whose registered 
office is 1 Broadland Business Park, Norwich, NR7 0WF. 
This message, and any attachments, are intended solely for the addressee and 
may contain privileged or confidential information.  If you are not the 
intended recipient, any disclosure, copying, distribution or any action taken 
or omitted to be taken in reliance on it, is prohibited and may be unlawful.  
If you believe that you have received this email in error, please contact the 
sender immediately. Opinions, conclusions and statements of intent in this 
e-mail are those of the sender and will not bind a Bertram Group Ltd company 
unless confirmed in writing by a director independently of this message. 
Although we have taken steps to ensure that this email and any attachments are 
free from any virus, we advise that in keeping with good computing practice the 
recipient should ensure they are actually virus free.


As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.