Hi Tricia,
What is the advantage of using a DAO?
I'm not sure if I am the right person to answer this question, but I'll
give it a try. Quoting from Wikipedia at
http://en.wikipedia.org/wiki/Data_Access_Object:
"Data Access Objects are a Core J2EE
<http://en.wikipedia.org/wiki/Java_2_Platform%2C_Enterprise_Edition>
Design Pattern and considered best practice. ... Data Access Objects can
be used in Java
<http://en.wikipedia.org/wiki/Java_%28programming_language%29> to
insulate an application from the underlying Java persistence technology
<http://en.wikipedia.org/wiki/Java_Persistence_API>,"
Anyway, my own view on this is that DAO, as any design patterns, is not
useful per se, but only in certain situations. In fact, when I wrote my
first applications using Cocoon and Hibernate, I simply called Hibernate
directly from the flowscript layer.
However, as my applications got more and more complex, this turned out
to be really messy. Doing all the data access on the flow layer had -
for me - one big disadvantage: I had to do it in JavaScript, while all
the classes I used and Hibernate itself were written in Java. The
obvious mismatch between the two leads to a lot of issues, from proper
exception handling to having to use weird syntax for "delete" methods
(hs["delete"](obj), for example, since delete is a reserved keyword in
JS). Furthermore, I simply missed my Eclipse and a strongly-typed
language like Java seemed better suited for complex operations on
business data. In the end, all the (luckily, few) applications I started
like this have now grown into an ugly, unmanageable mess.
Personally, I think that flowscript is one of the main (and honestly,
few) advantages Cocoon still has over other web application frameworks,
but this strength only shows if you use it *just what it was designed
for*, i.e. *control of page flow*. All non-trivial operations on
bussiness data should, IMHO, *not* be done in flowscript. This means
that you have to do them somewhere else - and here, the DAO pattern
comes in handy. Using it, I have finally been able to code some
applications in Cocoon and Hibernate I can actually be proud of.
I hope this gives you an Idea of why I'm recommending to use DAOs, but
still, I do not think that this must necessarily be the right approach
for everybody, just because it is "considered best practice".
Cheers,
Johannes
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]