The charges against them can be summarized in that they are complex, and provide only a leaky abstraction over a relational data store. Their complexity implies a grueling learning curve and often systems using an ORM perform badly – often due to naive interactions with the underlying database.
I think that if you’re going to dump on something in the way many people do about ORMs, you have to state the alternative. What do you do instead of an ORM? The cheap shots I usually hear ignore this, because this is where it gets messy. Basically it boils down to two strategies, solve the problem differently (and better), or avoid the problem. Both of these have significant flaws.
This is where the criticism comes that ORM is a leaky abstraction. This is true, but isn’t necessarily a reason to avoid them. Mapping to a relational database involves lots of repetitive, boiler-plate code. A framework that allows me to avoid 80% of that is worthwhile even if it is only 80%. The problem is in me for pretending it’s 100% when it isn’t. David Heinemeier Hansson, of Active Record fame, has always argued that if you are writing an application backed by a relational database you should damn well know how a relational database works. Active Record is designed with that in mind, it takes care of boring stuff, but provides manholes so you can get down with the SQL when you have to. That’s a far better approach to thinking about the role an ORM should play.
I’m guilty of trash-talking ORMs but I also am a huge fan of ActiveRecord. I appreciate Martin Fowler’s ability to articulate the advantages and trade-offs of the ORM and also the other approaches.
The Atlantic has a project called Life Up Close that I enjoyed. My favorite quote is from someone on foot in the rainforest of Peru, upon seeing a live jaguar: “He was running, really mad, angry, roaring, showing his teeth, hair bristling—and stopped about 10 or 12 meters from us and then jumped off the road,” he recalls. “We almost shitted our pants.” – Yep, that makes sense to me
An excellent Kent Beck post about partitioning complexity. I learned a couple new tricks from this, and often found myself nodding my head. I already use many of these tactics, but I didn’t have names for them (and never really thought deeply about them). The one I notice most people find novel is the “Predict test results”. I use this one all the time.