Should the ORM be used uniformly in the team? What is the disadvantage of using SQL statements?

Source: Internet
Author: User
Title.
The team size is 10 people. The programming environment is PHP + Python.
Personally, when everyone has SQL, and you have some SQL skills, using SQL statements uniformly can be more intuitive in future performance tuning. I do not know what you have been "people" have any ideas.
Is there any need to re-encapsulate the Phpredis function as an ORM in the Model? Feel that Redis itself is for the speed of existence, if again at the entrance to add some analysis, judgment, encapsulation, is not contrary to the theme of Redis, and the Model involved in data interaction in our team only 2 people responsible, coding standardization problem should not be a problem.

Reply content:

Title.
The team size is 10 people. The programming environment is PHP + Python.
Personally, when everyone has SQL, and you have some SQL skills, using SQL statements uniformly can be more intuitive in future performance tuning. I do not know what you have been "people" have any ideas.
Is there any need to re-encapsulate the Phpredis function as an ORM in the Model? Feel that Redis itself is for the speed of existence, if again at the entrance to add some analysis, judgment, encapsulation, is not contrary to the theme of Redis, and the Model involved in data interaction in our team only 2 people responsible, coding standardization problem should not be a problem.

One of the bigger problems with SQL is the unrestricted (or limited) right. A written error in an SQL statement can ruin all the data for the entire system.

So even WordPress, almost all of the frameworks are not advocating directly to hard code SQL statements in the program, but must be encapsulated.

Do not think that only two people do not have to encapsulate-the lack of rules, people are less.

Some of the lightweight ORM can be used, and the benefits are:
1, development fast, a lot of details encapsulated, such as the use and release of database connection
2. Object-oriented development approach makes code easier to understand and maintain
3. Do not limit your SQL tuning at all, such as a lightweight ORM like MyBatis or using SQL to access data

There are some AR class on the net, do a use, do not write directly SQL, if you want to adjust performance you can add a layer of logging specifically record slow queries and methods.
I've seen a lot of people put Redis into an ORM interface, for ease of use, parcels of some judgment and loading that are too normal, we can as needed for Redis Orm, Cache, Count, queue separately encapsulated, this performance has little impact. The most important is the acceleration of development and maintainability.

The advantage of using SQL is intuitive, but the disadvantages outweigh the benefits, such as low maintenance of hard-coded, poor front-end staff you can not guarantee that each person writes the same SQL, the main thing is the writing speed is slow, I think the database statements such things, front-end developers should not even direct contact.

In the project, more inclined to write SQL directly, rather than using ORM, for weakly typed languages such as Python. SQL Express ability is very strong, relatively simple, easy to get started.

The benefits of programmers learning SQL are:
1. SQL statements, can be executed at the command line (MySQL) & other graphical tools, while modifying, debugging.
2. On the Internet, there are a lot of SQL documentation, and there are fewer ORM documents. It's easier to find answers when you have difficulties.
3. SQL is more general, you may learn a lot of ORM, but do not understand SQL, you can say you know the ORM?

Programmers, familiar with SQL, and thus the database, are on their own request. This may be a DBA, but it's also your way of improving and adding value.

You can refer to the Discuz package, and all of the SQL-related changes are carried out in about 2 people review

Http://www.cnblogs.com/needrunning/archive/2011/11/15/2250068.html

Personally feel

Benefits of using ORM

1. 节约时间,指的是程序员的时间,如果题主不是做效率要求很高的东西,整个团队节约下来的时间是很客观的,非常喜欢一句话“宁花机器一分,不花程序员一秒”,题主选择了python,相信应个对这个体会比较深吧(生命苦短,我用python~)2. 适合工程,对同一类需求,基本上不同人写出来的东西是一样的,sql有这种问题,如果一个人写了很复杂的东西,这个成员离职或怎样,这段代码就会变成野草(非常难看懂,非常痛苦),早晚会被之后的维护者重写的,orm的话代码逻辑比较清晰。

The downside of ORM

1. 效率,orm的话会存在一些效率的问题,毕竟编译的时候会生成一些别的代码,可能一个复杂的需求写4、5十行sql的效率 > orm的效率,不过实在是很蛋疼2. 学习成本,很多人都是先学sql,然后接触orm,自然有学习成本的问题,而且使用orm就要符合orm的规范,有些高效的orm使用方式还是一种隐藏的附加技能,需要不断探索

In comprehensive

For a team that takes the programmer's time as the first person (project overtime is a normal thing), if the execution efficiency of the program is not very high, it is absolutely easy for you to use ORM.

  • 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.