tailieunhanh - PROGRAMMING IN PYTHON 3 - PART 8

Tham khảo tài liệu 'programming in python 3 - part 8', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | 422 Chapter 9. Debugging Testing and Profiling What kind of hypothesis might we think up Well it could initially be as simple as the suspicion that a particular function or method is returning erroneous data when certain input data and options are used. Then if this hypothesis proves correct we can refine it to be more specific for example identifying a particular statement or suite in the function that we think is doing the wrong computation in certain cases. To test our hypothesis we need to check the arguments that the function receives and the values of its local variables and the return value immediately before it returns. We can then run the program with data that we know produces errors and check the suspect function. If the arguments coming into the function are not what we expect then the problem is likely to be further up the call stack so we would now begin the process again this time suspecting the function that calls the one we have been looking at. But if all the incoming arguments are always valid then we must look at the local variables and the return value. If these are always correct then we need to come up with a new hypothesis since the suspect function is behaving correctly. But if the return value is wrong then we know that we must investigate the function further. In practice how do we conduct an experiment that is how do we test the hypothesis that a particular function is misbehaving One way to start is to execute the function mentally this is possible for many small functions and for larger ones with practice and has the additional benefit that it familiarizes us with the function s behavior. At best this can lead to an improved or more specific hypothesis for example that a particular statement or suite is the site of the problem. But to conduct an experiment properly we must instrument the program so that we can see what is going on when the suspect function is called. There are two ways to instrument a program intrusively by inserting .

TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
crossorigin="anonymous">
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.