I think there is a difference between tieing things to struts, and ojb.

Struts is quite obtrusive - you have to use Actions if you're going to use
struts.  Keeping business logic in actions ties you to struts.  If you
decided to add a swing interface to your app, then you cant easily reuse
this code.  If you'd kept the code in a struts-independant layer, you could
reuse it straight away.

OJB is quite unobtrusive (if used cleverly).  Now lets say you tie your
business logic into OJB. If you decide you want to switch to straight JDBC
you need to redo the business logic code to use JDBC, and remove references
to OJB.  But if you'd used the DAO pattern you'd only have to rewrite all
the DAOs and services tied to OJB - pretty much the same coding as if you
had tied your business logic directly to OJB.  So it doesnt reduce the
coding necessary.  There are hidden benefits though.  Instead of wading
through your entire app, you know where ALL the OJB specific code is - in
the DAOs.  The other big benefit is that you can have the OJB DAOs, and JDBC
DAOs coexisting, and pick which set to use on a given deployment.  If you
use IOC techniques, flipping from one to the other could only invlove
changeing a single classname, probably in an xml config file.

Now as you rightly stated, if you know you're only ever going to use OJB
then this isnt an issue. Which is my case, as i am not going back to JDBC!!!

As an interesting side, if you use OJB, and make all your classes extend a
BaseBO class (which only need have an primaty key "int id;" +getter/setter)
you can make a single DAO which will handle CRUD for all classes which
extend it.  I tend to take this approach. Would make swapping to JDBC a
pig - that would be a big switch statement and a LOT of JDBC code to do
that!

Daniel.

> -----Original Message-----
> From: Jim Barrows [mailto:[EMAIL PROTECTED]
> Sent: 15 December 2004 20:25
> To: Struts Users Mailing List
> Subject: RE: OJB && struts
>
>
> No big surprise that it works.   The DAO pattern is for
> abstracting out implementation details of how you actually talk
> to your DB.  If you know that you will always use OJB for your
> data access, then you don't need the DAO layer.
> If you know that you will never use anything but struts for your
> front end, then you don't even need a Business Object layer.  You
> can do it all in your action classes.
> HOWEVER, even if you think you know these things.... the future
> is unpredictable.  Which is why you implement the patterns, to
> accomodate not only radical changes, but minor ones as well.
>
>
> > -----Original Message-----
> > From: aris [mailto:[EMAIL PROTECTED]
> > Sent: Wednesday, December 15, 2004 9:46 AM
> > To: Struts Users Mailing List
> > Subject: Re: OJB && struts
> >
> >
> > Hi liooil,
> > I'm using OJB in my struts application.
> >
> > At the beginning I used Druid to create the package with the beans
> > (BusinessObjects? or DTO as explained in
> > http://www.reumann.net/struts/lesson1/step4.do) and the
> > repository.xml file.
> >
> > Here you can find Druid: http://druid.sourceforge.net/index.html
> >
> > Then I've created a package of BusinessObjectsService that I
> > can call from
> > my Action (as explained in
> http://www.reumann.net/struts/lesson1/step5.do).
>
> I use the class of this package to store and retrieve data from
> the db using
> the PersistenceBroker as explained in the related OJB tutorial.
>
> I don't use the DAO pattern but it works...
>
> Hoping this help,
> aris.
>
>
>
>
> ----- Original Message -----
> From: "liooil " <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Wednesday, December 15, 2004 10:41 AM
> Subject: OJB && struts
>
>
> Hello world,
>
> I'm trying to connect my web to my db through OJB ...
> I found many threads relative to this topic (persistence, ...,
> whatever, ...)
> And after that, i feel fuzzy about all mentioned patterns :
> DAO, Broker, Business Delagate, and so on ...
>
> At this moment, i'm stuck with my ODMG/OJB Struts plugIn (like in
> Cavaness's Beer4all) and i don't how i could connect that to my
> DAO pattern.
>
> Code Exemples on topice are not numerous. Or they just ignore the
> whole chain needed for reliable production web.
>
>
> Any comments, links are welcome
>
> thx,
>
>
> liooil,
>
>
> ___[ Pub ]____________________________________________________________
> Inscrivez-vous gratuitement sur Tandaime, Le site de rencontres !
> http://rencontre.rencontres.com/index.php?origine=4
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
> --
> No virus found in this incoming message.
> Checked by AVG Anti-Virus.
> Version: 7.0.296 / Virus Database: 265.5.4 - Release Date: 15/12/2004
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to