Mongo Repository: You probably shouldn’t do this type of thing

Reading this on InfoQ, I was struck by this:

“The reason for the existence of MongoRepository, to me, is simple: it provides a very 'narrow' abstraction on top of the underlying MongoCSharp Driver that, to me, mostly hides all awesome possibilities it provides behind a simple interface that, basically, supports CRUD. This way you don't get too tempted to use all sorts of Mongo-specific functionality and thus high coupling between a project and mongo is minimized so that, should one ever decide to use a different persistence layer, the 'switch' can be made a bit easier.”

Unless you need to use this sort of thing, you probably shouldn’t use this sort of thing.  And if you need to use this sort of thing.  You should think about if you really need to do this sort of thing.

To be clear, I’ve no doubt MongoRepository itself is well coded and does what it is designed to do.

But, you aren’t going to need to switch persistence layers.  And if you are going to need to switch persistence layers, you are going to need to do work.  And ignoring the functionality of your persistence layer technology almost guarantees that you are going to end up with ‘lowest common denominator’ coding that, almost guaranteed, is going to suck more than if you used the technology of your persistence layer.

You probably also shouldn’t be using the Repository pattern either, but that’s another story.

posted on Tuesday, October 07, 2014 9:37 AM Print
No comments posted yet.

Post Comment

Title *
Name *
Comment *  
Please add 2 and 3 and type the answer here: