ASP two ways to debug programs

Source: Internet
Author: User
Tags comments end
Program

When you're debugging a program, sometimes it's a long, many, hundreds of lines of code, if you write the program is messy, at this time usually do not know what they wrote, some people are more lazy, like me, even a note does not write, but I have never been my program dizzy, generally speaking, Whether your program is a development model that is oriented towards the image, in the local program code, your program is still structured, if you do not divide a module into several small modules to do, but hundreds of lines or even thousands of lines of code in a module, then a problem, you may not cry too late, You have to find bugs all day long, even if your program runs without problems, but there are loopholes in the design .... You must be very tired to find, and analysis of other people's code is very tired, if they don't even have to leave a note, then you are not very painful?? So that programmers don't want to read code written by others ... And so on, now I would like to introduce you two debugging procedures, these methods are most suitable for parsing module code, can be a piece of code without any comment easily parse out its use, well first for you to introduce the first kind:

First, process number

The main body of the program is flow control, the process is clear, the whole program is understood, the method is simple: If your IDE development tool has a line to mark and can also be numbered features naturally convenient, if not the source program copy to Notepad, and then start to the control process number, for example:
1 for (a=1,a++,,)
{
2 if (a=10)
{
......
2}
1}
3 if (a=11)
{
printf ("Problem with Program execution")
9 ·

In the example above, the number rule is: When you see the first process Control, add a number at the beginning of it, then go down and find a process control to determine whether it is the old process end or new process started, if it is the end of the old process to mark this process at the beginning of the label, if the brain is confused, Do not know how many, just up until find the current largest label (but has been other concluding sentences accounted for can not count), in fact, you just see the label began to show the trend, then you now find the largest label is the marking of the end of the sentence------the process of marking!! Also, the label of each process is sequentially ascending, the more the inner flow, the label is the largest, the outermost label is the smallest. At the same time you can pay attention to the label, if your initial label has already marked the closing sentence, if it is, you should check, this concluding sentence is not a very obvious mistake, such as: My first label is one, that is, the second layer of the structure of the label is 1, But when I mark a closing sentence of 1, I find that there is one "}" left in the next line, which is obviously wrong, at this time there are two reasons, one, you label wrong, two, the program more than a concluding sentence, then you will have a good check, to find the error began to continue to do marking, until the mark, after the marked, You can start analyzing the program, as long as it's in the two identical labels, is a small module, you have each module of the general use of the analysis (plus comments), and then put the use of these modules together to see the entire program more detailed action flow and it can complete the task, In the comments can also be very intuitive to see the program in the problems (inconsistencies, parameters do not exist, data types do not match ...) Wait, it's easy to see.

Two, streamline the process

When you have a more complex program, the program has a large but flow control, a layer of one layer, see you dizzy Liao Disorderly, wish to smash the computer!!! ~~~ :( Alas, what can I do when I smash the computer??? But you really qibuguo, you simply delete the program it hundreds of lines, haha is not very enjoyable, but give everyone a piece of advice, don't forget to back up, save you and regret ~~~~~, the method is this: first you do not understand the process from the innermost start to delete, from the inside to the outer layer of the deletion, Do you want to find out the error of the program when you delete each layer??? No?? Go on!!! Until you delete the outermost layer, which is basically almost the case, it is possible to simplify the process in a step-by-step way where you cannot see the complex, until the problem is clearly visible!!!!



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.