Data access object: Difference between revisions

Content deleted Content added
Tag: references removed
m Reverting possible vandalism by 211.128.72.49 to version by Kku. Report False Positive? Thanks, ClueBot NG. (2935939) (Bot)
Line 12:
}}</ref> "Core J2EE Patterns" for that platform).
 
== Advantages ==
open source ORM products include [[Doctrine (PHP)|Doctrine]], [[Hibernate (Java)|Hibernate]], [[iBATIS]] and JPA implementations such as [[Apache OpenJPA]].
{{unreferenced section|date=February 2015}}
The advantage of using data access objects is the relatively simple and rigorous separation between two important parts of an application that can but should not know anything 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 do not affect DAO clients as long as the interface remains correctly implemented.
All details of storage are hidden from the rest of the application (see [[information hiding]]). Thus, possible changes to the persistence mechanism can be implemented by just modifying one DAO implementation while the rest of the application isn't affected. DAOs act as an intermediary between the application and the database. They move data back and forth between objects and database records.
[[Unit testing]] the code is facilitated by substituting the DAO with a [[test double]] in the test, thereby making the tests non-dependent on the persistence layer.
 
In the non specific context of the [[Java (programming language)|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. Technologies like [[Java Persistence API]] and [[Enterprise JavaBeans]] come built into application servers and can be used in applications that use a JavaEE application server. Commercial products like [[TopLink]] are available based on [[Object-relational mapping]] (ORM). Popular open source ORM products include [[Doctrine (PHP)|Doctrine]], [[Hibernate (Java)|Hibernate]], [[iBATIS]] and JPA implementations such as [[Apache OpenJPA]].
 
== Disadvantages ==
Potential disadvantages of using DAO include [[leaky abstraction]],{{Citation needed|reason=What kind of leak?|date=August 2014}} [[Duplicate code|code duplication]], and [[abstraction inversion]]. In particular, the abstraction of the DAO as a regular Java object can hide the high cost of each database access, and can also force developers to trigger multiple database queries to retrieve information that could otherwise be returned in a single operation with normal SQL set operations. If an application requires multiple DAOs, one might find oneself repeating essentially the same create, read, update, and delete code for each DAO. This boiler-plate code may be avoided however, by implementing a generic DAO that handles these common operations.<ref>See http://www.ibm.com/developerworks/java/library/j-genericdao/index.html for workarounds</ref> Time consumption is moderate.{{Citation needed|date=December 2014}}
<!-- complete hogwash and speculation; original research with no sourcing whatsoever; title is "alternatives" in plural, while only one resemblance of alternative is presented. Commented out for now, maybe revive after there are several alternatives to DAOs
 
== Alternatives ==
DAO is a product of deep legacy thinking in which data objects in a computer's memory are '''translated''' into the [[third normal form]] data model of a relational database. This represents a significant overhead for development and maintenance and is usually chosen because of the desire to benefit from the productivity which can be derived from the use of [[SQL]].
 
[[XML]] is an alternative foundation on which to design and build a Persistence and Integration Strategy (which also includes Presentation) for modern software.{{Citation needed|date=December 2014}} When used with the objective of having minimal data format translation, whole systems can be built with XML that don't require the inherent data format translation of the DAO model.{{Citation needed|date=December 2014}} XML is self describing and self altering from the following points of view: 1) its schema can be defined in XML with .[[XSD]] files; and 2) it can be transformed using XML in the form of .[[XSLT]] and .[[CSS]] files. When combined with [[XQuery]] (replacing SQL), [[jQuery]], [[HTML5]], [[Extensible Application Markup Language|XAML]], [[JavaScript]], [[Node.js]], [[Atom (standard)]], ([[Representational state transfer|REST]]), [[JSON]], [[RAML (software)]] and databases like [[eXist]] and [[CouchDB]], software applications can be built with the "XML everywhere" model, which is agile, brief and powerful. In this model, the application design, work flow and configuration is also in XML, and each of these is used to assemble the Atom service calls into an XML application which talks to human beings, databases and other computer services with the same basic paradigm: XML. This approach also provides an advantage when targeting mobile apps by using an HTML5 Compiler. -->
 
== Tools and frameworks ==