Appearance
1.4 Identifying and Correcting Errors 识别与纠正错误
Developers create and innovate using an iterative design process that is user-focused, that incorporates implementation/feedback cycles, and that leaves ample room for experimentation and risk-taking.
- 开发者使用以用户为中心的迭代设计过程进行创造和创新,该过程包含实施/反馈循环,并为实验和风险承担留有充足空间。
核心要点 Core Points
A logic error is a mistake in the algorithm or program that causes it to behave incorrectly or unexpectedly.
- 逻辑错误是算法或程序中的错误,导致其行为不正确或意外。
A syntax error is a mistake in the program where the rules of the programming language are not followed.
- 语法错误是程序中没有遵循编程语言规则的错误。
A run-time error is a mistake in the program that occurs during the execution of a program. Programming languages define their own run-time errors.
- 运行时错误是程序在执行期间发生的错误。编程语言定义自己的运行时错误。
An overflow error is an error that occurs when a computer attempts to handle a number that is outside of the defined range of values.
- 溢出错误是当计算机尝试处理超出定义值范围的数字时发生的错误。
An round-off error is caused with operations on floating-point values; an example is a computer trying to store ⅓. A computer cannot store ⅓ since it has infinitely repeating digits. Each machine would manage this differently based on the fixed number of bits allocated.
- 舍入误差是对浮点数值进行运算时产生的误差;例如计算机尝试存储 1/3(三分之一)时就会出现这种情况。由于 1/3 的小数部分是无限循环的,计算机无法精确存储该数值。不同设备会根据其分配的固定位数(比特),采用不同方式处理这种情况。
The following are effective ways to find and correct errors:
- 以下是查找和纠正错误的有效方法:
- test cases 测试用例
- hand tracing 手工跟踪
- visualizations 可视化
- debuggers 调试器
- adding extra output statement(s) 添加额外的输出语句
学生活动 Student Activities
- For errors in an algorithm or program:
- 对于算法或程序中的错误:
- Identify the error. 识别错误。
- Correct the error. 纠正错误。
相关资源 Related Resources
- Professional Development > Teaching and Assessing Module: Explaining Processes from College Board
- 专业发展 > 教学与评估模块:解释过程 来自大学理事会
