Data access object
Data Access Object ( DAO , English for data access object ) is a design pattern that encapsulates access to different types of data sources (e.g. databases, file systems) in such a way that the addressed data source can be exchanged without having to change the calling code . As a result, the actual program logic should be freed from technical details of data storage and can be used more flexibly. So DAO is a pattern for designing programming interfaces (APIs). If a programming language does not allow a separation of interface definition and implementation, a DAO must implement the defined interface immediately.
properties
- DAOs do not completely abstract access to databases because they are not responsible for transforming the data into the structure of the database.
- DAOs are each optimized for a special storage medium. This medium is accessed via the API specified or to be implemented by the DAO.
- DAOs minimize the porting effort of an application when changing the storage medium.
Closely related to the Data Access Object is the Transfer Object design pattern . In cooperation with the DAO, this takes over the transformation of the data coming from the data source into the form required by the application. In object-relational mapping , object-oriented data are transformed into relational form.
Application examples
The pattern can also be found in the J2EE environment. Apple provides a similar concept called Enterprise Objects in the context of WebObjects .
Web links
- Core J2EE Patterns - Data Access Object. In: Core J2EE Patterns Catalog. Sun Microsystems