Re: Database development
On Mon, 26 Apr 2010, Arne Vajh?j wrote:
My preference is: if database need to be accessed by apps in different
technology, then it makes sense to put the business logic in SP's -
otherwise I would keep the business logic in the Java code, because that
makes it a lot cheaper to work with a different database -
It's worth mentioning that the modern alternative approach here is to put
hide the database completely behind the java, and expose the functionality
through web services. Rather than having other apps talk to the database
directly, they make calls to the java layer. That lets you raise the level
of abstraction in the other apps, reuse functionality in the java, and
maintain the invariants enforced by the business logic in the java.
The downside of this is that whatever it is the other app wants to do has
to be supported by the java app, which will invariably mean that
developing any app will involve some work on the java app to add the
needed capabilities. Mind you, if the DB-centric alternative involves
putting logic in stored procedures, then this is no different - external
apps will have to wrangle java code instead of PL/SQL or some other such
monstrosity.
Over time, the java app evolves into more of a service layer - at some
point, it makes sense to formally split it into the original app and a
service layer. That point might even be right at the start.
Also worth mentioning that if you're not afflicted by XMLitis, you can
also expose the services through CORBA or one of a myriad of other RPCish
mechanisms. Thrift! Protocol buffers! JSON-REST! DCE RPC! CSV-UUCP!
I would keep basic integrity check in the database though.
Same here. It should never be necessary, but it's nice to have a backstop.
If you can generate the constraints in the database automatically from the
code, then it's a no-brainer - would i be right in thinking that DDL
generated by popular JPA implementations puts in constraints wherever it
can? For example, FOREIGN KEY should be pretty easy. If you've got the new
javax.validation annotations on your entities, more constraints could be
generated from those too - is anyone doing that?
tom
--
Get my pies out of the oven!