Data Access Object

From Wikipedia, the free encyclopedia

Jump to: navigation, search
This article is about the Data Access Object design pattern in object-oriented software design. For the Microsoft library of the same name, see Data Access Objects.

In computer software, a Data Access Object (DAO) is an object that provides an abstract interface to some type of database or persistence mechanism, providing some specific operations without exposing details of the database. It provides a mapping from application calls to the persistence layer. This isolation separates the concerns of what data accesses the application needs, in terms of domain-specific objects and data types (the public interface of the DAO), and how these needs can be satisfied with a specific DBMS, database schema, etc. (the implementation of the DAO).

This design pattern is equally applicable to most programming languages, most types of software with persistence needs and most types of database, but it is traditionally associated with Java EE applications and with relational databases accessed via the JDBC API because of its origin in Sun Microsystems' best practice guidelines[1] ("Core J2EE Patterns") for that platform.

Contents

[edit] Advantages

The advantage of using data access objects is the relatively simple and rigorous separation between two important parts of an application which can and should know almost nothing of each other, and which can be expected to evolve frequently and independently. Changing business logic can rely on the same DAO interface, while changes to persistence logic does not affect DAO clients as long as the interface remains correctly implemented.

In the specific context of the Java programming language, Data Access Objects as a design concept can be implemented in a number of ways. This can range from a fairly simple interface that separates the data access parts from the application logic, to frameworks and commercial products. DAO coding paradigms can require some skill. Use of technologies like Java persistence technologies and JDO ensures to some extent that the design pattern is implemented. Technologies like EJB CMP come built into application servers and can be used in applications that use a JEE application server. Commercial products like TopLink are available based on Object-relational mapping. Popular open source products include Hibernate which is also based on ORM and iBATIS and Apache OpenJPA which is not based on ORM. The expected benefit of use of Data Access Objects in a Java scenario is

  • Improved efficiency and performance of the data layer since it is standard reusable software.[citation needed]
  • It is also expected that in case the DAO implementation were to change the other parts of the application would be unaffected.[clarification needed]
  • Resources are dedicated to develop and implement this layer which converts into better software in this layer.[weasel words]

[edit] Disadvantages

  • As with many design patterns, a design pattern increases the complexity of the application.[citation needed]
  • As is common in Java, there are many open source and commercial implementations of DAO available. Each of these can have potentially different implementation strategies and usage models. There is a familiarisation curve involved with each of them.[citation needed]
  • A certain amount of skill is required to implement a DAO design pattern or use a DAO product.

[edit] See also

[edit] External links

[edit] Tools and Frameworks

[edit] References

  1. ^ "Core J2EE Patterns - Data Access Objects". Sun Microsystems Inc.. 2007-08-02. http://java.sun.com/blueprints/corej2eepatterns/Patterns/DataAccessObject.html. 
Personal tools