There’s a really interesting debate on Prevayler vs. database usage for storing data going on over here at The Fishbowl: Prevayling Stupidity.
Lots of interesting points are made both for and against and when it is and isn’t appropriate to use an in-memory system like Prevayler, but one comment in particular stood out for me. It was this one:
And even if you have a dedicated machine, you have to wonder what happens if you’re providing some kind of service that gets really popular, really fast. Brad from Livejournal originally wrote the site to host him and a few friends. If he’d written it using Prevayler, it’d have fallen over the moment it got really popular, and today he wouldn’t be running a website with half a million users.
OK, now hidden in that statement is an instance of really bad design. I hope you see it but just in case you don’t, here’s what’s missing. Any application which is storing and retrieving data needs to have abstracted out all of that process into data access objects (DAO). Even if I’m writing something “for my friends” or “just for me” I assume nevertheless that I may someday change how I store and retrieve the data for my program. It may be something like a switch from database to Prevayler or from local storage to access via a web service to a remote server. Either way, because I’ve abstracted out the operations I need to perform I can write those quickly to get something which functions and then tune for performance later or completely replace the whole DAO implementation with another that simply implements the same interface.
So, take this to the bank, never never ever embed your data access in the rest of your application in such a way that you have to change any code in the meat of that application simply to replace something as simple as a persistence mechanism.