Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do I really need an ORM?

We're about to begin development on a mid-size ASP.Net MVC 2 web site. For a typical page, we grab data and throw it up on the web page, i.e. there is not much pre-processing of the data before it is sent to the UI.

We're now making the decision whether or not to use an ORM and if yes, which one. We had been looking at EF2 AKA EF4 (ASP.Net Entity Framework in VS 2010) as one possibility.

However, I'm thinking a simple solution in this case may be just to use datatables. The reason being that we don't plan to move the data around or process it a lot once we fetch it, so I'm not sure there is that much value in having strongly-typed objects as DTOs. Also, this way we avoid mapping altogether, thereby I think simplifying the code and allowing for faster development.

I should mention budget is an issue on this project, as well as speed of execution. We are striving for simplicity anywhere we can, both to keep the budget smaller, the schedule shorter, and performance fast.

We haven't fully decided this yet, but are currently leaning towards no ORM. Will we be OK with the no ORM approach or is an ORM worth it?

like image 677
alchemical Avatar asked Apr 30 '10 07:04

alchemical


People also ask

When should you avoid ORM?

If you know your data access pattern is going to be complex or you plan to use a lot of database-specific features, you may not want to use an ORM.

Why should I use an ORM?

ORM is a technique that lets you query and manipulates data from a database using an object-oriented paradigm. It encapsulates the code needed to communicate with the database, so you don't use SQL anymore; you interact directly with an object in the same language you're using.

Is it better to use ORM or SQL?

No Universally Best Choice Many developers will likely use SQL and ORM at different times. That's because there are instances when one is clearly the more appropriate option. However, it's too short-sighted to say that one is the best choice in all cases.

Do big companies use ORM?

Originally Answered: Does big company (etc, twitter, facebook, Dropbox) use Object-Relational Mapping on SQL DB? Yes. As an employee of Percona , I have done MySQL consulting for many big and small web-based companies.


3 Answers

An ORM-tool isn't mandatory!

Jon's advice is sensible, but I think using DataTables isn't ideal.

If you're using an ORM tool, the object model is far simpler than a full-blown OO domain model. Moreover, Linq2Sql and Subsonic, for example, are straight-forward to use. Allowing very quick code changes when the database changes.

You say you won't move the data around or process it a lot, but any amount of processing will be far easier in ORM objects rather than in DataTables. Again, if the application changes and more processing is required the DataTable solution will be fragile.

like image 178
Joe Ratzer Avatar answered Oct 29 '22 10:10

Joe Ratzer


If you're not going to practice full-blow Object Oriented Programming (and by that I mean you should have a very deep understanding of OOP, not just the ability to blurt out principles and design pattern names) then NO, it's not worth going for an ORM.

An ORM is only useful if your organization is fully invested in Object Oriented application design, and thus having the problem of having an Object to Relational model mapping. If you're not fully into OO, ORMs will become some sort of nasty roadblock that your organization will then feel it doesn't need.

If your team/organization's programming style has always leaned to keeping business logic in the DB (e.g., stored procs) or sticking to a more or less functional/procedural/static approach at writing objects and methods, do away with ORMs and stick to ADO.NET.

like image 33
Jon Limjap Avatar answered Oct 29 '22 10:10

Jon Limjap


It sound as if you only need to show data and dont do CRUD.

I have found that ORM is not the best way to go when displaying lists that consists of data from various tables. You end up loading large objectgraphs just to get this one needed field.

A SQL-statement is just so much better at this. I would still return lists of strongly typed objects from the DAL. By that you have a better chance of getting a compile time error when a change in the DAL is not reflected in other layers.

like image 45
Mathias F Avatar answered Oct 29 '22 09:10

Mathias F