Re: struts using jdbc
Richard Senior wrote:
I don't disagree. I wasn't in any way recommending Hibernate. But
coupling your data access mechanism of choice into Struts is bad
practice on larger applications.
I agree with pretty much everything you said in your post.
....
Of course re-use of data access code is possible and beneficial! The
quote above alludes to the same. It's basic programming good practice:
* Put calls to DAOs into a Business Delegate layer and call the
delegate rather than duplicating code and database level exception
handling across action classes.
* Make calls to the same API in other applications.
Is that not re-use?
I don't reuse all of the same API in other applications. I copy the same base
classes and re-extend to application-specific logic and entities. So it is
re-use and it isn't. Because each application winds up with different data
and logic, I can't reuse everything, and what I do resuse will just be the
interfaces and abstract classes.
So yes, it's reuse at one level. I should have specified that I meant that
the concrete implementations may not be reusable.
And yes, of course data access code is tightly coupled to the data model
and perhaps even the database. That's precisely why it should be
accessed via a clean business interface - so that your application isn't
coupled in the same way!
Yes - I practice this. I believe in isolating the data layer more than I do
in reusing it.
But the entities, the facts of the data model, perforce are present in every
layer, front to back. If you need someone's hair color, that'll be reflected
in the input forms and surface validation, the business logic and the data
structures. An app that doesn't care about hair color will not be able to
reuse those factors.
Likewise the logic - if you care about changing hair color your object model
and behaviors will be very different from those of an app that tracks payroll
deductions.
The reuse is at the abstract layer; the devil is in the implementation details.
--
Lew