25.12.2013 Views

Developer Notes - ITwelzel.biz

Developer Notes - ITwelzel.biz

Developer Notes - ITwelzel.biz

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

AddressDAO<br />

ContactsDAO<br />

Factory<br />

uses<br />

accesses<br />

selects/creates<br />

hsqldb<br />

Data Source<br />

PersonDAO<br />

Contact<br />

hsqldb<br />

ContactsDAO<br />

Client<br />

Service<br />

accesses<br />

Implements<br />

accesses<br />

CompanyDAO<br />

<br />

ContactsDAO<br />

accesses<br />

Figure 1: Implementation of the DAO design pattern for a DAO that accesses data for a<br />

business-contacts resource.<br />

<strong>Developer</strong> <strong>Notes</strong><br />

The DAO Interface<br />

Using the DAO pattern, a developer accesses a data source only in terms of its<br />

DAO interface. This approach shields the application or client service from<br />

modifications to the underlying data source. The following is an example of a<br />

DAO interface for a DAO that abstracts data and functionality for a data source<br />

that stores information for business contacts:<br />

public interface ContactsDAO<br />

{<br />

public Contact getContact(String personID,<br />

String addressID,<br />

String companyID)<br />

throws DAOException;<br />

public String addContact(String addStr)<br />

throws DAOException;<br />

public void modifyContact(String contactID,<br />

String modifyStr)<br />

throws DAOException;<br />

}<br />

public void deleteContact(Contact contact)<br />

throws DAOException;<br />

50<br />

www.novell.com/appnotes

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!