跳到主要内容

创造性开发

AP 计算机科学原理 · 第 1 主题

训练
讲义 词汇表
1.1

协作

大纲
Enduring UnderstandingLearning ObjectiveEssential Knowledge

CRD-1
Incorporating multiple perspectives through collaboration improves computing innovations as they are developed.

CRD-1.A
Explain how computing innovations are improved through collaboration. [Skill 1.C]

  • CRD-1.A.1 A computing innovation includes a program as an integral part of its function.
  • CRD-1.A.2 A computing innovation can be physical (e.g., self-driving car), nonphysical computing software (e.g., picture editing software), or a nonphysical computing concept (e.g., e-commerce).
  • CRD-1.A.3 Effective collaboration produces a computing innovation that reflects the diversity of talents and perspectives of those who designed it.
  • CRD-1.A.4 Collaboration that includes diverse perspectives helps avoid bias in the development of computing innovations.
  • CRD-1.A.5 Consultation and communication with users are important aspects of the development of computing innovations.
  • CRD-1.A.6 Information gathered from potential users can be used to understand the purpose of a program from diverse perspectives and to develop a program that fully incorporates these perspectives.

CRD-1.B
Explain how computing innovations are developed by groups of people. [Skill 1.C]

  • CRD-1.B.1 Online tools support collaboration by allowing programmers to share and provide feedback on ideas and documents.
  • CRD-1.B.2 Common models such as pair programming exist to facilitate collaboration.

CRD-1.C
Demonstrate effective interpersonal skills during collaboration. [Skill 1.C]

  • CRD-1.C.1 Effective collaborative teams practice interpersonal skills, including but not limited to:
    • communication
    • consensus building
    • conflict resolution
    • negotiation

来源:美国大学理事会 AP 课程与考试说明

计算是一个协作(collaborative)活动。在一个团队里工作带来更多视角、捕捉更多错误,并产生比单独工作更好的程序。好的协作使用共识建立(consensus building)、清晰的沟通和每个成员的长处。结对编程(pair programming)——两个人在一台计算机前,一个打字一个审查——是一个常见的做法。在考试上,你应当能够解释协作如何改进了一个程序(更多想法、更少 bug、更广的测试)。

词汇表 训练
英文 中文 拼音
collaborative 协作 xié zuò
Pair programming 结对编程 jié duì biān chéng
1.2

程序的功能与目的

大纲
Enduring UnderstandingLearning ObjectiveEssential Knowledge

CRD-2
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.

CRD-2.A
Describe the purpose of a computing innovation. [Skill 1.A]

  • CRD-2.A.1 The purpose of computing innovations is to solve problems or to pursue interests through creative expression.
  • CRD-2.A.2 An understanding of the purpose of a computing innovation provides developers with an improved ability to develop that computing innovation.

CRD-2.B
Explain how a program or code segment functions. [Skill 4.A]

  • CRD-2.B.1 A program is a collection of program statements that performs a specific task when run by a computer. A program is often referred to as software.
  • CRD-2.B.2 A code segment is a collection of program statements that is part of a program.
  • CRD-2.B.3 A program needs to work for a variety of inputs and situations.
  • CRD-2.B.4 The behavior of a program is how a program functions during execution and is often described by how a user interacts with it.
  • CRD-2.B.5 A program can be described broadly by what it does, or in more detail by both what the program does and how the program statements accomplish this function.

CRD-2.C
Identify input(s) to a program. [Skill 3.A]

  • CRD-2.C.1 Program inputs are data sent to a computer for processing by a program. Input can come in a variety of forms, such as tactile, audio, visual, or text.
  • CRD-2.C.2 An event is associated with an action and supplies input data to a program.
  • CRD-2.C.3 Events can be generated when a key is pressed, a mouse is clicked, a program is started, or any other defined action occurs that affects the flow of execution.
  • CRD-2.C.4 Inputs usually affect the output produced by a program.
  • CRD-2.C.5 In event-driven programming, program statements are executed when triggered rather than through the sequential flow of control.
  • CRD-2.C.6 Input can come from a user or other programs.

CRD-2.D
Identify output(s) produced by a program. [Skill 3.A]

  • CRD-2.D.1 Program outputs are any data sent from a program to a device. Program output can come in a variety of forms, such as tactile, audio, visual, or text.
  • CRD-2.D.2 Program output is usually based on a program's input or prior state (e.g., internal values).

来源:美国大学理事会 AP 课程与考试说明

每个程序都为一个目的(purpose)而写——它解决一个问题或追求一个兴趣。一个程序接受输入(input)、处理它,并产生输出(output)。输入能来自一个用户、一个设备、一个文件,或另一个程序;输出能是视觉的、听觉的、文本的,或给一个设备的一个信号。能够陈述一个程序的目的,并清晰地描述它的输入和输出,是一项核心技能(以及创建性能任务的一部分)。

每个程序分解成输入、处理和输出
每个程序分解成输入、处理和输出
每个程序遵循输入-处理-输出模型
每个程序遵循输入-处理-输出模型
探索

Explore the input → processing → output model

Step through the IPO model. Every program takes some input, performs processing on it by following its instructions, then produces output — trace one weather-app example along the pipeline.

词汇表 训练
英文 中文 拼音
input 输入 shū rù
output 输出 shū chū
1.3

程序设计与开发

大纲
Enduring UnderstandingLearning ObjectiveEssential Knowledge

CRD-2
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.

CRD-2.E
Develop a program using a development process. [Skill 1.B]

  • CRD-2.E.1 A development process can be ordered and intentional, or exploratory in nature.
  • CRD-2.E.2 There are multiple development processes. The following phases are commonly used when developing a program:
    • investigating and reflecting
    • designing
    • prototyping
    • testing
  • CRD-2.E.3 A development process that is iterative requires refinement and revision based on feedback, testing, or reflection throughout the process. This may require revisiting earlier phases of the process.
  • CRD-2.E.4 A development process that is incremental is one that breaks the problem into smaller pieces and makes sure each piece works before adding it to the whole.

CRD-2.F
Design a program and its user interface. [Skill 1.B]

  • CRD-2.F.1 The design of a program incorporates investigation to determine its requirements.
  • CRD-2.F.2 Investigation in a development process is useful for understanding and identifying the program constraints, as well as the concerns and interests of the people who will use the program.
  • CRD-2.F.3 Some ways investigation can be performed are as follows:
    • collecting data through surveys
    • user testing
    • interviews
    • direct observations
  • CRD-2.F.4 Program requirements describe how a program functions and may include a description of user interactions that a program must provide.
  • CRD-2.F.5 A program's specification defines the requirements for the program.
  • CRD-2.F.6 In a development process, the design phase outlines how to accomplish a given program specification.
  • CRD-2.F.7 The design phase of a program may include:
    • brainstorming
    • planning and storyboarding
    • organizing the program into modules and functional components
    • creation of diagrams that represent the layouts of the user interface
    • development of a testing strategy for the program

CRD-2.G
Describe the purpose of a code segment or program by writing documentation. [Skill 4.A]

  • CRD-2.G.1 Program documentation is a written description of the function of a code segment, event, procedure, or program and how it was developed.
  • CRD-2.G.2 Comments are a form of program documentation written into the program to be read by people and do not affect how a program runs.
  • CRD-2.G.3 Programmers should document a program throughout its development.
  • CRD-2.G.4 Program documentation helps in developing and maintaining correct programs when working individually or in collaborative programming environments.
  • CRD-2.G.5 Not all programming environments support comments, so other methods of documentation may be required.

CRD-2.H
Acknowledge code segments used from other sources. [Skill 1.C]

  • CRD-2.H.1 It is important to acknowledge any code segments that were developed collaboratively or by another source.
  • CRD-2.H.2 Acknowledgement of a code segment(s) written by someone else and used in a program can be in the program documentation. The acknowledgement should include the origin or original author's name.

来源:美国大学理事会 AP 课程与考试说明

程序通过一个迭代(iterative)过程构建,不是一条直线:调查问题和用户、设计(常常带一个(diagram)或书面计划)、以代码实现,并测试——然后重复。一个大问题被分解成更小的片段(分解(decomposition))。注释(comments)和清晰的命名记录设计,以便其他人(以及你未来的自己)能理解它。开发是增量(incremental)的——构建并测试一个小片段,然后添加下一个。

程序开发的阶段,测试反馈以修复和精化
程序开发的阶段,测试反馈以修复和精化
软件由一个迭代的、增量的开发过程构建
软件由一个迭代的、增量的开发过程构建
探索

Loop through the iterative development process

Development is iterative — you repeat the stages, improving the program a little on each pass. Step around the loop and notice it returns to the start rather than ending after one run.

词汇表 训练
英文 中文 拼音
iterative 迭代 dié dài
decomposition 分解 fēn jiě
Comments 注释 zhù shì
1.4

识别与纠正错误

大纲
Enduring UnderstandingLearning ObjectiveEssential Knowledge

CRD-2
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.

CRD-2.I
For errors in an algorithm or program:
a. Identify the error. [Skill 4.C]
b. Correct the error. [Skill 4.C]

  • CRD-2.I.1 A logic error is a mistake in the algorithm or program that causes it to behave incorrectly or unexpectedly.
  • CRD-2.I.2 A syntax error is a mistake in the program where the rules of the programming language are not followed.
  • CRD-2.I.3 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.
  • CRD-2.I.4 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.
  • CRD-2.I.5 The following are effective ways to find and correct errors:
    • test cases
    • hand tracing
    • visualizations
    • debuggers
    • adding extra output statement(s)

CRD-2.J
Identify inputs and corresponding expected outputs or behaviors that can be used to check the correctness of an algorithm or program. [Skill 4.C]

  • CRD-2.J.1 In the development process, testing uses defined inputs to ensure that an algorithm or program is producing the expected outcomes. Programmers use the results from testing to revise their algorithms or programs.
  • CRD-2.J.2 Defined inputs used to test a program should demonstrate the different expected outcomes that are at or just beyond the extremes (minimum and maximum) of input data.
  • CRD-2.J.3 Program requirements are needed to identify appropriate defined inputs for testing.

来源:美国大学理事会 AP 课程与考试说明

一个 bug 是一个程序里的错误;调试(debugging)是找到并修复它。三种:

一张跟踪表在程序运行时记录每个变量的值,以找到 bug
一张跟踪表在程序运行时记录每个变量的值,以找到 bug
  • 一个语法错误(syntax error)破坏语言的规则,所以程序不会运行;
  • 一个运行时错误(runtime error)在它运行时使程序崩溃(例如除以零);
  • 一个逻辑错误(logic error)让它运行但给出错误的结果。

通过用不同的输入(包括边界情况)测试、添加打印语句(print statements)以看值,以及手工跟踪代码来找 bug。一次修复一个 bug 并重新测试是可靠的方法。

考试技能: 能够命名一个错误的类型并描述一个会捕捉它的测试策略——一个反复出现的选择题和创建任务主题。

三种编程错误:语法、逻辑和运行时
三种编程错误:语法、逻辑和运行时

Worked example. 一个本应打印两个数平均值的程序却运行了 avg = a + b / 2。追踪运算顺序,/+ 之前运行,所以它计算 $a+\tfrac{b}{2}$ 而不是平均值。加括号来修复:avg = (a + b) / 2。用已知输入 $a=4,\ b=6$ 测试确认修复——有错误的行给 $4+3=7$,修正后的行给 $\tfrac{10}{2}=5$。用已知输入测试正是你找到并确认一个逻辑错误的方法。

探索

Trace the guessing-game logic and spot a logic error

Drag the guess and watch which branch runs. A logic error would send the same guess down the wrong branch — the program still runs, but gives the wrong message. The secret number here is 50.

词汇表 训练
英文 中文 拼音
debugging 调试 tiáo shì
syntax error 语法错误 yǔ fǎ cuò wù
runtime error 运行时错误 yùn xíng shí cuò wù
logic error 逻辑错误 luó jí cuò wù
1.4

考试技巧

  • CSP 的很多部分通过创建(Create)和书面性能任务评估——清晰地解释你的推理,不只是你的结果。
  • 知道协作的好处以及多样的视角如何减少一个程序里的偏见。
  • 当你描述一个设计过程时使用精确的词汇(迭代开发、程序需求)。
  • 建设性地给出和接受反馈;为协作者和来源署名。
  • 把一个大问题分解成一个团队能并行构建的更小的模块。

本主题的互动课程

逐步学习,并即时检测练习。

AP 计算机科学原理历年真题

AP 计算机科学原理的更多主题

登录或创建账号

IGCSE, A-Level & AP