手机APP下载

您现在的位置: 首页 > 行业英语 > 计算机英语 > 计算机专业英语教程 > 正文

计算机专业英语教程第2版 第20期:程序调试与维护

来源:可可英语 编辑:clover   可可英语APP下载 |  可可官方微信:ikekenet

If your program exits abnormally, then there is almost certainly a logical error (a bug) in your program. 99% of programming is finding and removing these bugs. Here are some tips to help you get started.

如果你的程序非正常退出,很有可能你的程序中有逻辑错误,或称之bug。99%的程序工作是要找出并去除这些bug。下而是对一些初学者的提示。
Before going on, it is necessary to reiterate the standard OLC policy on program debugging: Do *NOT* ask OLC for help debugging a program.This stock answer is intended to give you some tips on how to get started in this area; however, in general, program debugging requires more time and effort than consultants are usually able to provide.
首先,有必要重复关于程序调试的标准OLC规则:不要请求OLC帮助调试程序。这一备用答案用来给出一些关于在这一领域怎样开始的提示。但总的来说,程序调试需要的时间和努力比咨询者通常所能提供的更多。
The first step is to find the exact line where the program exits. One way of doing this is with print statements scattered through your code. For example, you might do something like this in your source code:
第一步是找出程序出错的精确的语句行。实现的方法是在程序代码中分散布置一些打印语句。例如,你可以在源程序中做如下工作:
程序.pngThe fflush() command in C ensures that the print statement is sent to your screen immediately, and you should use it if you're using printf() for debugging purposes.
C语言中的fflush()命令使得输出立即被送到显示器上,如果你的print f()是用于调试目的的就要用到fflush()。
Once you have narrowed down the line where your bug occurs, the next step is to find out the value of your variables at that time. You will probably find that one of your variables contains very strange values. This is the time to check that you have not done the following things:
当气你找到了bug发生的行,下一步就是要找出当时的变量值。你可能会发现某个变量值很奇怪。这时候就要检查你有没有做下面的事情。
—Assigned an integer value to a pointer variable; or

——给指针变量赋予一个整数值:或者

—Written to a subscript that is beyond the end of an array (remember that in C array subscripts go from 0 to N-1, not from 1 to N.)
——数组的下标越界。(记住,C数组的下标是从0到N-1。不是从1到N。)
Other mistakes also cause bugs. Make sure that your loops test correctly for their end conditions, for example.
别的错误也会引起bug,例如要确认循环测试的边界条件使用正确。
Other kinds of bugs (programs not exiting, incorrect output) are debugged using similar methods. Again, find the line where the first error occurs, and then check the values of your variables. Once you fix a bug, recompile your program, run it again, and then debug it again as necessary.
其他类型的bug(程序不终止,错误输出)用同样的方法进行调试。再一次找到第一个错误发生的行,检查变量值。当你处理了一个bug后,重新编译程序,再次运行。如果需要还要再调试。
Using print f() is a primitive method of debugging, but sometimes it's the only one that will work.If your program is too big for a debugger (such as Saber or Ddbx) or if you are working on a non-Athena platform, you may not have a debugger available. Usually, though, it is quicker and easier to use a debugger. Athena has several sophisticated debugging tools available. Saber is the tool of choice for C programmers. Gdb and Dbx may also come in handy, and both of these work with Fortran as well as with C. There are stock answers that introduce Saber and Dbx, and Saber even comes with a tutorial.
使用print f()是调试程序最原始的方法,但有时却是惟一有效的方法。如果你的程序对一个调试器(如Saber或Dbx)来说太大,或者你使用的是非Athena平台,你可能没有合适的调试器。通常,使用调试器会更快更容易。Athena有几个好用的调试工具,Saber 是C程序员的工具选择,Gdb和Dbx使用也很方便。并且适用于Fortran和C。有许多介绍Saber和Dbx的现成答案,甚至还有Saber的辅导材料。
It is a fact of life in program design but there seems to be always one last bug or error to be corrected.We can broadly classify the errors as:

程序设计中有这样的情况,就是好像永远有一个bug或错误有待改正。错误的大体分类如下:

Syntax errors—this class of error means that a mistake is made in the language used to state the algorithm.

•语法错误——这一类错误出现在表示算法的语言中。

Logic errors—the algorithm is syntactically correct but doesn't do what is intended.

•逻辑错误——表示算法的语讲法是正确的,但得不到预期结果。

Data range and data type errors—the algorithm is syntactically correct and logically correct but can be threatened by the wrong kind of data or by values which are out of range.
•数据范围和数据类型错误一一算法的语法和逻辑都正确,但是有错误数据类型或超出范围的数据值对程序造成威胁。
The syntax errors aren't a serious issue during the program design phase since in practice, after designing and testing the design, the program will be implemented in a computer program language and it is at this point that syntax errors become a problem. Even so syntax errors are a minor problem since the process of building the program will capture the errors. The program simply won't build until all the syntax errors are removed.
程序设计阶段,讲法错误不是一个严重问题,当设计完成并测试后,要用某一种汁算机语言实现程序,这时语法错误才成为需要处理的问题。但即使这样,语法错误也是小问题,因为在程序形成阶段会发现错误。只有语法错误淸除后才形成程序。
The logic errors are a much more serious problem since there is no way to eliminate these other than rigorously testing the program design.
逻辑错误是较为严重的问题,因为没有办法可消除逻辑错误,除非彻底测试程序设计。
The data errors are also serious errors and in some respects are harder to deal with than logic errors.
数据错误也是严重错误,有时比逻辑错误更难处理。
Once launched, the program needs to be maintained. Definition for program maintenance is that updating programs from time to time keeps abreast of changes in an organization's needs or its hardware and software. Based on the maintenance tasks needed to be performed, the program administrators should determine on-going financial and staffing needs and how they will be met. Program maintenance represents a major portion of the total expenditures on application programs.
当投入使用后,程序需要维护。程序维护的定义就是根据组织需要或硬件、软件改变的情况不断地更新程序。基于要实现的维护任务,程序管理员需要决定后续经济支持和人员需要及配备。程序维护是成用程序总体花费中的主要部分。

重点单词   查看全部解释    
stock [stɔk]

想一想再看

n. 存货,储备; 树干; 血统; 股份; 家畜

 
portion ['pɔ:ʃən]

想一想再看

n. 部分,份,命运,分担的责任

联想记忆
screen [skri:n]

想一想再看

n. 屏,幕,银幕,屏风
v. 放映,选拔,掩

 
determine [di'tə:min]

想一想再看

v. 决定,决心,确定,测定

联想记忆
minor ['mainə]

想一想再看

adj. 较小的,较少的,次要的
n. 未成年

联想记忆
reiterate [ri:'itəreit]

想一想再看

vt. 反覆地说,反覆地做

联想记忆
classify ['klæsifai]

想一想再看

vt. 分类,归类

联想记忆
abreast [ə'brest]

想一想再看

adv. 并肩地,赶得上

联想记忆
issue ['iʃju:]

想一想再看

n. 发行物,期刊号,争论点
vi. & vt

 
maintenance ['meintinəns]

想一想再看

n. 维护,保持,维修,生活费用
n. 供给,

联想记忆

发布评论我来说2句

    最新文章

    可可英语官方微信(微信号:ikekenet)

    每天向大家推送短小精悍的英语学习资料.

    添加方式1.扫描上方可可官方微信二维码。
    添加方式2.搜索微信号ikekenet添加即可。