PHP Code Maintenance, refactoring 4 reasons for difficulty analysis, 4 reasons for Analysis _php tutorial

Source: Internet
Author: User

PHP Code Maintenance, refactoring 4 reasons for difficulty analysis, 4 kinds of cause analysis


This paper analyzes the 4 reasons why PHP code maintenance and refactoring becomes difficult. Share to everyone for your reference, as follows:

Code maintenance, refactoring is a very unpleasant thing. The following scenarios make it difficult to maintain and refactor code.

1. At the beginning of the project, we have set some code specifications, under certain specifications for development, but the human mind is not the same, that is, each function of different people to achieve the logic may have such a difference, resulting in some people do not want to see others code, to change others code, The first thing to know is what the man was thinking and what his logic was. So there are a lot of people's idea is to have that look at other people's code time, I will do it again. This idea does not have, see other people's code also can learn a lot of things. If you think like this, I think the redundancy code will be more and more, later refactoring will become more and more difficult.

2. The general procedure of job hopping is more frequent, the project started, is 5 people (project founder) developed, and other projects on-line, may have been left. The staff is not enough, the company recruit. Project founder, the new people, not too believe, afraid to modify the original code will lead to the function of the problem, so there is a fresh rule, it is best not to modify the online program, if the demand changes, it is best to re-write class or function, so that the code will become more and more. There may be several classes that are similar to each other, or functions of more than one function.

3. Database redundancy fields, too many redundant tables, can also make code maintenance very difficult. Because of functional optimization, or new requirements, resulting in the original table structure can not meet the new requirements, this time, will go to the table to add fields, or hook up another table, long-term past, the database becomes very bloated, the database is a big, the code certainly needless to say, the program is around the data, redundant fields, redundant tables to maintain, Otherwise the data will not be unified. The necessary redundancy can reduce the database query, if too much, will only get it back. So when you modify the database, you have to consider clearly, consider the future of the database and code to be refactored.

4. Personal reasons are the most important reason, first of all to have the idea of chunking, also can be said to be oop thought, this idea is in the actual combat, this is to be a certain time. Don't neglect the overall consideration in order to be quick to implement the function. If there is a new need, I will first consider how to achieve this demand, with the idea, I will not rush to develop this feature, I will also consider this function module, will not be used in other places? If other places to use, how to make other places to use more convenient. I will let this function module be called where the interface has only one. Then I will start to develop. Also, do not believe that demand will not change, no. People have a lot of ideas, the development of code, this is also taken into account, so the unified interface in the demand changes, I just modify a place, other places can be changed. If this is considered, early development, time will be a little more, but later maintenance is much faster.

Summary, with the above 4 points, refactoring the database, refactoring the code will be inevitable

1. People's thoughts cannot be the same, we all try to think of one place, but there is always such a difference.
2. Be anxious to complete the function without getting into the code of others. It is not good to study others ' code as quickly as it is to be re-developed.
3. Database redundancy, this I personally feel that inevitably will appear, a project bigger, stronger, must be in constant growth, growth process, the database can not be static.
4. Lack of block thinking, I think a project, is a lot of functional independent small pieces through a certain string up, code refactoring is to put these small pieces of the re-composition, of course, the small pieces in the reconstruction before and after the implementation of the function will be different, but it is to achieve a certain function, but from the old to new only.

The above points are I actually encountered in the development project process, welcome to add.

More interested in PHP related content readers can view the topic: "PHP Basic Grammar Introductory Tutorial", "PHP Object-oriented Programming tutorial" and "PHP Excellent Development Framework Summary"

I hope this article is helpful to you in PHP programming.

Articles you may be interested in:

    • Implement maintenance file code with PHP
    • Maintaining file systems with PHP
    • Five PHP code refactoring tools recommended
    • The five simplified function calls of "refactoring-improving the design of existing code" in PHP
    • The four simplified conditional expressions for "refactoring-improving the design of existing code" in PHP
    • The three re-organization data of "refactoring-improving the design of existing code" in PHP
    • PHP talk about "refactoring-improve the design of existing code" between the two objects of the moving characteristics
    • PHP "refactoring-improve the design of existing code" one of the re-organization of your function
    • Rephactor Excellent PHP refactoring tools

http://www.bkjia.com/PHPjc/1095681.html www.bkjia.com true http://www.bkjia.com/PHPjc/1095681.html techarticle PHP Code Maintenance, refactoring, 4 reasons for difficulty analysis, 4 reasons analysis This paper describes the PHP code maintenance, refactoring is difficult to 4 reasons. Share to everyone for your reference, specific as ...

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