The ORM framework of my development framework

Source: Internet
Author: User

Today I would like to share my own ORM framework, although the talk is not very good, but I personally think it is very nice to share with you to exchange.

First of all, let me say something about my current mainstream ORM framework:

Advantages:

    1. Let programmers no longer focus on database details, focus on business logic, programmers can not understand the database can be developed system.
    2. Make the database migration is very convenient, if the system needs to change the database used, the direct modification of the configuration is good, do not control the differences between the different database syntax.
    3. Time-saving, rapid development, because you do not need to write complex SQL statements, do not need to encapsulate complex data underlying, which can save a lot of time.

Disadvantages:

    1. I think the programmer who doesn't understand the database is not a good programmer, and ORM doesn't help you generate all the business statements, it's complicated to generate, or you need to write SQL, such as complex reports.
    2. The formulation is too cumbersome, error after the location of the problem is not easy.
    3. Performance is low, because it uses a lot of reflection, and database detection, resulting in performance is necessarily low.
    4. Additional learning costs are required, although you do not need to learn the database, but you need to learn the ORM statement.
    5. Prone to irregular development, because ORM can write ORM statements anywhere and then invoke development, so that for the initial programmer they are likely to throw an ORM statement anywhere in the system, which makes maintenance a lot more difficult.

Because I have not been optimistic about these ORM framework so shortcomings write a little bit more, there may be some advantages I do not know, passing people if they know can give me a message, I make up.

Now let's talk about my own ORM framework, which is called the ORM Framework because it also achieves several of the advantages of the ORM framework above.

First of all, based on the data manipulation layer, I wrote a method based on the operation database of the image extraction DBHelper

Then based on this dbhelper I developed the abstract data manipulation engine, and expanded the different database support here only shows the MySQL, and mssql,access in fact, all the supported ADO database can be extended

After doing so, my framework can be database agnostic, I can use any database, even can mix up the database.

Now I'll talk about how to quickly develop and let programmers not focus on SQL statements.

For programmers, there's nothing more straightforward than looking at the code, I'll show you the code:

Here demonstrates the addition and deletion of the method, first here I did not write a SQL, nor ORM statements, the wording should be more intuitive, our data model has been extended to the fields are added to the attributes.

If I want to set the value of a field, I will set its isvalue to true, if I want to query a field I will set its iscolume to true, I personally understand this way closer to OOP thought, more straightforward and easy to understand, at least I now bring new people let them use this can quickly get started, Almost no pressure.

This also avoids the novice programmer casually write SQL statements, but also easy to maintain and manage, and rapid development, the most important is the performance is very high, because I do not use reflection, and do not need the ORM statement to the SQL statement translation, but also can be customized only to query out some of the fields (now as if some ORM does not reach this effect).

Then someone might say that your physical model must be very complex, to write this must be very time-consuming, in fact, this sentence is half, because the solid model is really complicated, but it does not take time, because I mentioned in the previous blog, my entity model is all automatically generated, do not need manual to operate, Including my data layer code, it is really very large and complex, but does not require manual processing, one step to generate it directly can be used.

Well, today introduced here, my framework of the specific details of follow-up I will be slowly introduced in detail, interested can see. At the same time, we welcome the valuable comments on my framework.

The ORM framework of my development framework

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.