Persistence is a Solved Problem

Comments

Confession: as someone who came from a procedural and very much “roll your own persistence code” background, I still sometimes find myself thinking a bit too much about persistence when I’m writing Rails code. There are plenty of articles out there telling you that separating persistence from your domain model is the One True Way, and plenty that say it’s overcomplicating matters for simple problems. It’s just so easy to rails g model Blah name:string […] and start slinging code in that model file.

True, it is easy. But, you know what? Persistence is a solved problem. Granted, solved in any one of about a hundred different ways, depending on what you’re up to, but solved.

Recently, I’ve been finding it incredibly freeing to model a domain as if persistence didn’t matter. That’s right. Ignore its very existence. Put it out of my mind, completely. It helps me think more clearly about the problem I’m really trying to solve. Once that part’s figured out, I’m in a better position to make a reasoned decision about which persistence solution fits, and what concessions I’m willing to make, if any.

comments powered by Disqus