Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Manual DAL & BLL vs. ORM

Which approach is better: 1) to use a third-party ORM system or 2) manually write DAL and BLL code to work with the database?

1) In one of our projects, we decided using the DevExpress XPO ORM system, and we ran across lots of slight problems that wasted a lot of our time. Amd still from time to time we encounter problems and exceptions that come from this ORM, and we do not have full understanding and control of this "black box".

2) In another project, we decided to write the DAL and BLL from scratch. Although this implied writing boring code many, many times, but this approach proved to be more versatile and flexible: we had full control over the way data was held in the database, how it was obtained from it, etc. And all the bugs could be fixed in a direct and easy way.

Which approach is generally better? Maybe the problem is just with the ORM that we used (DevExpress XPO), and maybe other ORMs are better (such as NHibernate)?

Is it worth using ADO Entiry Framework?

I found that the DotNetNuke CMS uses its own DAL and BLL code. What about other projects?

I would like to get info on your personal experience: which approach do you use in your projects, which is preferable?

Thank you.

like image 919
Mikhail Glukhov Avatar asked May 24 '09 23:05

Mikhail Glukhov


People also ask

How does a full denture receive its support and retention?

The atmospheric pressure outside the dental base presses it firmly onto the oral mucosa. Good adsorption is mainly ascribed to a thin sticky layer of saliva between the dental base and oral mucosa that contributes greatly to retention.

What is relief RPD?

Relief is used to create a space between the framework and the cast or soft tissue. Relief is also used beneath framework extensions, in edentulous area to provide for attachment of denture bases, and to form internal finish lines.

How many appointments are needed to fabricate a partial denture?

Removable Partial / Full Denture Replacing the teeth is important for eating, speaking, supporting the facial muscles, and of course restoring your smile! A series of 5 appointments are needed in order to fabricate a customized denture. During the first appointment, an impression is made and sent to the lab.


1 Answers

My personal experience has been that ORM is usually a complete waste of time.

First, consider the history behind this. Back in the 60s and early 70s, we had these DBMSes using the hierarchical and network models. These were a bit of a pain to use, since when querying them you had to deal with all of the mechanics of retrieval: follow links between records all over the place and deal with the situation when the links weren't the links you wanted (e.g., were pointing in the wrong direction for your particular query). So Codd thought up the idea of a relational DBMS: specify the relationships between things, say in your query only what you want, and let the DBMS deal with figuring out the mechanics of retrieving it. Once we had a couple of good implementations of this, the database guys were overjoyed, everybody switched to it, and the world was happy.

Until the OO guys came along into the business world.

The OO guys found this impedance mismatch: the DBMSes used in business programming were relational, but internally the OO guys stored things with links (references), and found things by figuring out the details of which links they had to follow and following them. Yup: this is essentially the hierarchical or network DBMS model. So they put a lot of (often ingenious) effort into layering that hierarchical/network model back on to relational databases, incidently throwing out many of the advantages given to us by RDBMSes.

My advice is to learn the relational model, design your system around it if it's suitable (it very frequently is), and use the power of your RDBMS. You'll avoid the impedance mismatch, you'll generally find the queries easy to write, and you'll avoid performance problems (such as your ORM layer taking hundreds of queries to do what it ought to be doing in one).

There is a certain amount of "mapping" to be done when it comes to processing the results of a query, but this goes pretty easily if you think about it in the right way: the heading of the result relation maps to a class, and each tuple in the relation is an object. Depending on what further logic you need, it may or may not be worth defining an actual class for this; it may be easy enough just to work through a list of hashes generated from the result. Just go through and process the list, doing what you need to do, and you're done.

like image 161
cjs Avatar answered Sep 27 '22 17:09

cjs