Nick’s Blog

ORM Why?

by Nick on Mar.08, 2011, under Development

Or more precisely why not! I guess I could be counted as one of those old school developers that is now just a little stuck in his ways. I started writing software more than thirty years ago and I have seen a lot of progress in my time. There is little doubting that writing an application now is far easier than it ever was and developers now are free to focus on the problem rather than having to focus on how to solve the problem.

An ORM  framework (object relational mapping) allows a developer to create objects in the problem domain and largely ignore how or where they are persisted. Well that’s the theory. It has been my experience that actually getting an ORM framework to work efficiently is an oxymoron. How can something that abstracts the storage possibly do so efficiently, because for each possible storage mechanism there will be different requirements to achieve efficiency.

I came across the following site ( while thinking about what it is I do not like about ORMs. And I think the best argument on that site was actually the one by Ken Downs. If I can summarise it like this I hope I do his arguments justice. He says that data generally outlives the applications that use that data, so modelling that data correctly in the database is way more important than how it is represented in the application. This has been my experience too. You write an application and it gathers data and ultimately fashions change and someone says can we now have a version that runs on Windows rather than Unix, the Web rather than Windows, my smartphone rather than the web. When I was working at KLM (more than ten years ago) one system celebrated it’s 30th birthday. So it must be at least 40 now. I bet the user interface has changed countless times in those 40 years while the data model will have grown but largely remained related to the original model.

I’ve just started a new job. I don’t want to embarrass the previous company too much but they are about to undertake rewriting their product for the web. Currently it is a Windows based application that uses an ORM framework so that data can either be stored in Oracle or SQL Server. Every object in the problem domain is derived either directly or indirectly from one base class and for each class in a specific objects inheritance hierarchy their is a table. This means that there is a table in the database that has an entry for every single object in the system and when you update any object that and all other tables are locked. You might not be too surprised to find that performance is an issue.

When I started working with them the question “Who is the DBA?” was answered with “We don’t have one”. Well that came as such a shock. I wanted to see the data model written out somewhere. I wanted to know who was allowed to make changes to the data model and who was responsible for migrations. “We all are!” was more or less the answer. You might expect that they might take the chance to change to a more efficient system with a migration to the web. However with over 200 very large customers you really cannot go about making big changes. The data is too valuable to mess it up. And yet it is not the data that has driven their design. It is the design that has driven the data.

So what about the argument that using an good ORM makes the design portable? I’ve just started messing around with NHibernate. I followed a tutorial on the web site and found a number of problems in the tutorial but finally got it all working. I had a class called product and then an interface for a repository and then a class that implements this interface but fair enough it did work. It even allowed me to have the system generate the schema in the database and I even got it working on two different databases with only a minor change in a configuration file. But suppose that the little test application had required something more sophisticated than simply adding or removing items from a very short list of items. Suppose it had wanted to know which five items were the cheapest this week out of the thousands that are on sale. What would I have had to do? Load them all up into memory and sort by price ascending and only retrieve the first five rows? Perhaps! Frankly I don’t know. What I do know is that in virtually all RDBMS systems this and other queries can be quickly and easily answered by most developers using the powerful database abstraction mechanism that is SQL. That’s right, SQL is a kind of standard, OK it has been bastardised by various manufacturers over the years but they all more or less do it the same way. However once I’ve learned how to achieve the results I want with NHibernate I will then have to learn it all over again when I move to the next framework.

The bulk of the projects that I work on are GIS related. I have never heard anyone saying that performance is not an issue for a specific project because it seems in the GIS world the temptation is to throw layer after layer onto the map and then each time the user pans or zooms we have to reload all that data. There is no shortcut

:, ,

Comments are closed.

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Founder chanel replica founded the Chanel brand in Paris, France in 1913. replica gucci wide range of products, including clothing, jewelry and accessories, cosmetics, perfume, each product is famous, especially her hermes replica and replica bags . Chanel is a famous brand with more than 80 years of experience. Chanel fashion always has elegant, simple and exquisite style. She is good at breaking through the tradition. She successfully pushed the fake bags of “Five Flowers” to simple and comfortable in the 1940s. This is perhaps the earliest modern casual wear.