Java Best Practices and DB Redux

From Artima.com: John O'Hanley has created a site dedicated to collecting Java best practices.

I took a look and it's not bad. Bullet point do's and dont's accompanied by sample code. I was going through Data Access Objects today... it was helpful. I ALWAYS like back to basics info even if I think I know a technology. It's always good to review. Many times (hell most of the time) I'm completely off base about a few things.

This past week at work all I did was look at DB Persistance stuff. Dave's graph was a great start... I also was exploring TopLink more in detail. Here's my thoughts: Always looking for standards and doing "the right thing" I originally thought JDO was what I was after, since it's a Sun spec. However, the only two OSS projects are lacking and the commercial JDO companies aren't any that I've ever heard of. Until Sun, Oracle, IBM or whomever comes out with (and heavily backs) their implementation, I'm not going to bother wishing for JDO support. Also JDO in general just may be a bad idea... And hell, if I'm going to work with a bad idea, I might as well use CMP.

I started thinking along these lines when I read Carlos' response to Dave's graph a few days ago and it just made inherent sense to me:

Now, I've worked with ODMG, and JDO is nothing more than a cleaned up ODMG api. Something analagous to JDOM being a cleaned up API over DOM. I've got to tell you, the concepts are completely out of wack, and the idea of object transparency is as bogus as the idea of remote object transparency.

Here's a use case where ODMG and it's JDO cousin break: Display only the name and description of a collection of fairly large objects. It's a typical use case that you find in any project that requires some kind of navigation or query. What you need here is a single feature, that is the ability to take a subset of the attributes of classes. That is, in SQL "select name, description from myobject", that simple. Try that with ODMG and tell me if you can do it, that is create thousands of partial objects, without of course inhaling the entire object graph.

So, if you think ODMG or JDO are important features, think again. It's simply not worth the extra baggage. Just take a look at Sun's JDO site, don't know what's worse this or ExperimentalStuff! JDO is one prime example of vendors railroading a JCP specification, fortunately it was developed by lesser vendors like Versant and Poet. JDO is a spec developed by OODBMS vendors, its not a spec developed by OO-Relational mapping vendors, that in my opinion makes a whole lot of difference.

It makes sense. Also, in one of the JDO frameworks I saw, they wanted to modify my .class file after I had compiled it, aparently sactioned by the spec. WHAAAAT? Don't freakin' TOUCH my class file after it's compiled, Mr. Smart Guy OO Developer. It all seems well and good with you testing it on your P4 2Ghz at the office, but when I throw it on a HP-UX machine running some wacky JVM in the middle of France, I want to know EXACTLY why some error could have occurred, not guessing if you screwed up my byte code in the process.

Anyways, having gotten rid of my initial JDO bias, I just started looking at what would do the job and decided that TopLink is actually really cool. It's expensive - $7000 a server - but not as much as it used to be with Bea's classic $2000 a pop for developers. It meets all the criteria in Dave's graph for top down, middle out and bottom up. You can have the mappings as an XML file or a generated Java class (where you can modify the code for tweaking) and more. I'm not sure what my company's problem with it actually is... I think it's a matter of consistency. Part of the app we're developing uses TopLink and the other parts don't and they want to figure out how to get things unified for easier maintenence. Since the TopLink stuff wasn't developed by them, that's why they wanted me to look at it. And instead of coming away thinking it's a bloated, over-rated piece of code, I actually think the opposite. Especially after comparing it to the other stuff out there.

I think in general, my favorite is Hibernate - which seems to be easy and straight forward way to do anything you need along these lines and is open and free. Castor also didn't seem bad, but something rubs me the wrong way about it... I'm not sure what. These are sort of "my picks" since I normally do development for myself without the benefit of corporate sponsers. But where my company is concerned I'm going to see if they want to use TopLink more because if they've already paid for the licenses, it seems like a good industrial-grade choice to me. And now that Oracle owns it, it's going to have a longer life than before.

I'm running on empty... more detail will just have to come later (if ever).

-Russ

< Previous         Next >