PHP project "Bitter force" experience and considerations

Source: Internet
Author: User
The experience and thinking of "Bitter force" in PHP project

PHP The experience and thinking of "bitter force" in the project

PHP 0 is based on the foundation, but due to insufficient staffing of the project, it is arranged to a user "custom" project. This project is a statistical report generated in PHP . And the user has 3 new requirements, need to be completed on the basis of existing code.

First , initial knowledge PHP

Since I have not been exposed to PHP code Engineering, it takes a little time to get through PHP 's basic syntax. Personal feelings like C + + , there are class definitions, inheritance and derivation, but it is much simpler than C + + , there is no concept of C + +,C data type, All the data would like to use the direct declaration of the assigned value. And, its string is very powerful, can be nested definition, is C 's string, struct, union, enumeration type and so on the composition, is "skill".

To have a general understanding of the basic grammar, some general functions are currently used to investigate.

Second, the code structure carding

Characteristics of custom projects: on the basis of the relative perfection of the existing functions, Add or modify new features to meet user's "custom" requirements . Requirements will have "* * Requirements Specification" for reference.

Because the project period is short, basically is straight to the topic. the keyword search method was used during the period to narrow the scope of the code. But because the code structure is very large, and "ancestors" less to code comments, the entire code follow-up progress has been very slow. No sense of direction, feel the code "jump to jump", and back to the initial reading place, "string does not line."

The whole process lasted 5 days, and the turtle moved ahead.

Third, to find the "entrance", realize the function

To achieve user needs, the following steps are required to achieve the "panorama" perspective of new or modified functionality from the project:

The first step: Find "code" new or modified entry point , possibly more than one, may involve multiple PHP documents, in the course of the daytime code, for these "Doubtful" all have to dike and Callout a sign that makes it easy for you to find.

Step two: in read "Questionable" code logic Add or modify code based on it, and test it over and over again until you reach the customer's function.

The third step: the formation of a patch package or incremental package, submit testing department test, to be tested after the user acceptance.

The first step is very critical and often takes nearly half the time of the whole project.

Period Required combining the implementation of new features with the existing code framework to think to find the "entrance". For example, where does the data come from to implement new data for the report? Data may be related to MySQL database, to obtain statistical classification data from the database, how is the existing data obtained? Is the acquisition of the new statistics to be achieved by modifying the SQL statement? How to modify? Does this change the foreground to display correctly? Does it need to be verified by the station? ...

Iv. thinking

From the point of view of efficient achievement of the project and the bitter experience of crying without tears, I think about the following points for cross-language development and future projects.

First, "工欲善其事, its prerequisite ".

read the code early, due to the discoverySourceinsightthePHPcode support is not good, so usenodepad++to read the code, it's differentPHPthe pain of the file code jump is visible. Later, the search found actuallySourceinsightthePHPis supported, users have to provide configuration methods. In this way, search keywords and code jump and more efficient. Later, from the master where found that the code of this foreground can actually be passedsubline Text2To read, test, and indeed good, has been used to the present.

So, good code editing, compiling tools will make your thinking relatively smooth, improve work efficiency.

Second, "Shun Vine can touch melon."

How complex the code, as long as others can write and can realize the function, we can't understand. Do not "dozens", do not complain about the code comment is not enough, calm down to spend some time to "shun Rattan", to straighten out the code logic, so that you can gradually build a code framework of the overall thinking.

"Shun Rattan" on the one hand can be the day code to shun, when the code logic is very complex, you can pass Print Log the way to print key functions to straighten out the calling relationship of the code. The combination of the two methods will do more.

initially, due to time, you can first draw a flowchart with your bare hands for the daytime code reference. When the project summary, then draw a standard flowchart for later use.

"Rattan" straightened out, new and modified code will not be so cumbersome. It was also stressed that "shun Vine" time is far greater than the "touch melon" time. So, early to have patience, remember impetuous.

Third, Details very important.

I need to add new members to the array when I modify the code. Mistakenly " datarow "written" daterow php php file gets new add-on that is always not available. I gradually narrowed down the scope to the area written, before the function, inside the function, after the function of the new log printing comparison. This still does not find the root cause of the problem. But the confirmation problem is in the Write section, and the last near 1 days to find out where the problem is

in fact, similar errors, some of the compilation environment can be avoided by "completion", and some languages will also report grammatical errors. But careful is the essential quality of the programmer when warning.

IV. Not too much, one by one.

The project needs a long time, see so many needs and a few times easy to make themselves messy. Therefore, the need to be one to achieve. Do not catch, Cluth often become an hourglass, can only catch a little. After a small function has been implemented, be aware of your Next. So next,next , the project will be relatively compact.

2014-6-18 pm20:58 think at home in front of the bed

Author: Ming Yi World

Reprint please indicate source, original address: http://blog.csdn.net/laoyang360/article/details/32173571

If you feel this article is helpful, please click on the ' top ' support, your support is I insist on writing the most power, thank you!

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