Go The pros and cons of Orm

Source: Internet
Author: User

Orm[object-relation-mapping] Object Relational mappings. This noun has been out for several years. It's not strange. Previously, a domain model-driven approach to business overview, analysis, and modeling was used in the project for relatively complex business logic.  The first time I touched the concept of ORM in the design phase.  The NHibernate implementation of ORM in real-world projects enables the persistence of underlying data. Of course, there are already many tools for ORM to mature. The purpose of this article is to combine the previous practical programming experience. The system organizes the ORM prototype concept.

<1> What is ORM?

It is not difficult to explain the noun. Let's look at the Orm's origins. In fact, the real reason for ORM's demand is the development of object oriented OO programming development method. OO programming for object-oriented [object] is now a mainstream development approach in enterprise-level development. The relational database also becomes the mainstream data storage system for permanent storage of data in enterprise-level application environment. In fact, you should understand that. The same data is in the actual programming of an object-oriented approach, and the other is to persist this memory object to the hard disk file.

It can be said that objects [object] and relational data are two different representations of business entities. The business entity object behaves as an object in memory and behaves as relational data in the database.

There are associations and inheritance relationships between objects in memory, and in a database, relational data cannot directly express many-to-many associations and inheritance relationships. Therefore, object-relational mapping (ORM) system usually exists in the form of middleware, which mainly realizes the mapping of program object to relational database data.

Then someone would ask why the ORM is needed.

Start with the data flow storage form in the project. Simply take MVC as a layered model. The model acts as a data-hosting entity. Data between the user interface layer and the business logic layer is implemented in object-oriented oo form delivery.  We will find out when we need to persist the data through the control layer distribution request. How does object-oriented oo in memory persist an actual data record in relational data?

Object-oriented is developed from the basic Principles of software engineering (such as coupling, aggregation, encapsulation), and the relational database is developed from the theory of mathematics. There is a mismatch between the two. Orm as a project middleware to achieve data relationship mapping in different scenarios. Object Relational mapping (relational Mapping, ORM) is a technique to solve the non-matching phenomena between object-oriented and relational database. That's how ORM comes in.

<2>orm effect and advantages and disadvantages?

ORM is launched to some extent to break our architectural design. It also brings some problems that haven't occurred before using ORM. But the most important thing is that coding efficiency is improved. You can free up more energy and time from the repetitive work of the underlying data access layer code. Focus on the program and the business itself. This is when ORM leads to increased programmer productivity

The other one has to say is the cost of maintenance. We used to build a huge complex data access layer with ADO. I think the MVC architecture UI and control can be decoupled between layers and layers. While the data access layer DataAccess layers, it is associated with business logic. Modify the underlying data access layer when there is a slight change. This maintains frequency and flexibility. It is a great deal of criticism. It is conceivable that maintenance costs are very costly and laborious.

ORM embodies the features:

<1> Improve development efficiency . The ORM Framework automates the mapping of the attributes of entity entities to relational database fields. CRUD work can be handed out to ORM to generate code from the implementation. Play to improve our development efficiency. This also reduces the cost of maintaining a complex and inflexible data access layer.

<2>nosql Data Manipulation . The NOSQL database has only been proposed in recent years to be used in some open source databases. Similar to Repid DB, the ORM does not need to manipulate the T_SQL statement directly to achieve data manipulation. In fact, as the founder of Hibernate, Gavin King is completely unaware of how t_sql is used in designing hibernate. This makes a lot of people sweat.

<3> said the current ORM this model disadvantage.

It is believed that many of the herberate or. NET versions of. Nherberate should be understood. After we have built the project structure. Do a good job of accessing the XML database configuration file. You can then easily implement CRUD operations of data based on data entity Entitymodel. NoSQL operations have made our development efficiency a qualitative leap forward. But when the project is in the middle of the test, our DBA sees the database connection SQL statement saying, "is f**k link so long that SQL is sick?" "Why do you say so?"

Suppose our DBA encounters something like this scenario . Like we now do a system access verification. 6 table associations are implemented between database design tables. In the case of large data volumes. CRM gives us the ability to generate some inefficient access to SQL as our performance has never gone. Although the code is generated automatically but you see nherberate not every time the generated code is high performance to meet your needs. So your DBA said to you the other day, "which xx xxx." Do you have this interview done in SQL Optimizer? "Back to the day:" That is nherberate automatically generated and I have what relationship? "DBA:" So very crazy said a multi-connection situation t_sql will be as many access to the deadlock? must be optimized. "Back to the day:" When nherberate automatically generated I can't change it? The DBA "crashes directly from extreme madness ..."

There's a story to be invented . Previous use of Nherberate to illustrate CRM with a process:

The definition of CRM is to some extent sacrificing the execution performance and fixed thinking mode of the program.

A: First, from the system architecture, ORM is used as the underlying data access layer. Architectures are mostly multi-tiered architectures. The more hierarchical the system architecture, the more efficient the programmatic execution of the object-oriented approach. Similar to a common support multi-data Architecture approach MyBatis ORM Framework architecture in such a way as:

B: Performance issues . In using CRM as the data access layer in the system architecture. Most of our data crud operations are given to CRM to generate code in a way that is implemented. However, CRM built-in auto-generated code is only automatically generated according to the rules of object relationships. This is similar to what happens above. This situation requires the use of additional tools and configuration policies to flexibly implement CRM data access.

An ORM prototype concept is briefly described above. To understand the concept can be more aspects after the CRM operation. If you have any questions, please put them in your message.

[Advantages and disadvantages of]orm

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.