DB: it’s a matter of balance
It was since the beginning of my career as a software developer that I’ve seen too many devs building their so called OO apps on top of some database.
I mean those apps were nothing without a DB and things like event notifications were done (”are” done, actually) through the db: some polling task looking at a table for new things to do.
Every of these projects has a common pattern:
- they are started thinking at the database, and the objects structure and hierarchy is a consequence of the relational structure of the tables
- db fans have built a perfectly normalized db, but it is slow: too many “joins”, indexes that cannot be created because the DBAs fear the loss of speed (remember: fear is a consequence of ignorance. If you fear something, you don’t know something). DBAs de-normalize the db, keeping it in sync through stored procedures and triggers.
- the customer asks for some new feature that would have been just as simple as a decorator, BUT since your object hierarchy is still reflecting the DB structure, you realize very soon that you would need to modify a couple of different classes instead than adding one. And because you fear (fear! again) to modify your code, you ask the DBA to adapt the DB structure to your needs: and so views, stored procedures and functions start to pop up like pustules.
- step 3 is repeated ad nauseam for a whole year or so. The team is exhausted by the continous effort put on maintaining the app (that’s what I call “kick programming”, that’s stacking quick, dirty and violent solutions to small problems). Some of the older team members leave as they like to be programmers, not maintainers. Junior developers replace them, and things go worse, as a junior may not have enough experience and being new to the team means he/she doesn’t know the app well enough to keep on maintaining it even at the low quality level of the old programmers.
- I still don’t know, I’ve never seen that, but I know there is still some fifth point. Maybe the project is kept on by people who “just code”, continously patching the whole thing. Maybe the project dies. Maybe something else…
All this mess JUST because someone has given the DB more importance than it deserves.
Remember: a database is a place where you put things when you leave the office, because you’ll need them the day after. Period.
It’s a base to put data on: no logic, no influence on the project.
Have you ever thought at your desk drawer as a player in your project management or design process? I don’t think so.
September 30th, 2007 at 11:25 am
So? Which is the solution? :) Is there a part two for this post?
(pustules! you’re a damn genius!)
September 30th, 2007 at 11:50 am
argh, yeah, re-reading it for the Nth time, I too find it a bit hard to get.
The solution is to be pragmatic and to think at the db as a desk drawer. It will happen someday that you’ll need it to sync in someway with something else, and so you’ll use triggers and stored procedures: just limit the number of them, because your job is to keep the business logic consistent, not to waste time trying to understand why that damn row wasn’t inserted into the damn table!
Thank you for the genius ;)
October 1st, 2007 at 2:01 am
What about updating db server and to not let dba denormilize well-made databases? I’m a bit scared from using a not reliable database structure.
Are already present best pratices to build “Agile-DB”?
October 1st, 2007 at 8:04 am
http://www.agiledata.org/ has some info and a bunch of links about being agile in managing databases
BTW, I would (personally) prefer to have some abstraction layer to take care of it, instead of me. Some ORM lib or ruby’s active record with its “migrate” feature
October 5th, 2007 at 9:15 am
Don’t steal my business logic!
I agree with you, and this is a post from a live project (still live after a year, I don’t known :) ) :
http://www.request.to.it/frank/index.php?entry=entry061020-102039
Ah, I leaved it!