跳到主要内容

创造性开发

AP 计算机科学原理 · 知识点 1

本主题的视频课程 打开视频页面
6:15

创意开发

这里有一个程序应该打印两个数字的平均值。它运行了。它没有崩溃。它打印了一个答案——但答案是错误的。给它四和六…

英语旁白 · 英中内嵌字幕

1.1

协作

教学大纲

持久理解(CRD-1): 在开发计算创新的过程中,通过协作融入多种视角能够提升计算创新的质量。

学习目标 CRD-1.A: 解释如何通过协作改进计算创新。[技能 1.C]

  • CRD-1.A.1 计算创新包含一个程序作为其功能的重要组成部分。
  • CRD-1.A.2 计算创新可以是物理形式的(例如自动驾驶汽车)、非物理的计算软件(例如图像编辑软件),或是非物理的计算概念(例如电子商务)。
  • CRD-1.A.3 有效的协作能够产出反映设计者多样化的才能与视角的计算创新。
  • CRD-1.A.4 纳入多元视角的协作有助于避免计算创新开发过程中的偏见。
  • CRD-1.A.5 与用户进行咨询和沟通是计算创新开发的重要环节。
  • CRD-1.A.6 从潜在用户处收集的信息可用于从多元视角理解程序的目的,并据此开发充分融合这些视角的程序。

学习目标 CRD-1.B: 解释计算创新是如何由人群团队共同开发的。[技能 1.C]

  • CRD-1.B.1 在线工具支持协作,允许程序员共享想法和文档并提供反馈。
  • CRD-1.B.2 结对编程等常见模式旨在促进团队协作。

学习目标 CRD-1.C: 展示协作过程中有效的人际交往技能。[技能 1.C]

  • CRD-1.C.1 高效的协作团队践行人际交往技能,包括但不限于:
    • 沟通
    • 达成共识
    • 冲突解决
    • 谈判

来源:College Board AP 课程与考试说明

English
A jigsaw in progress: collaboration and modular design piece the solution together
A jigsaw in progress: collaboration and modular design piece the solution together

Computing is a collaborative 协作 activity. Working in a team brings more perspectives 视角, catches more errors, and produces better programs than working alone. Good collaboration uses consensus building 达成共识, clear communication, and each member's strengths. Pair programming 结对编程 – two people at one computer, one typing and one reviewing – is a common practice. On the exam, you should be able to explain how collaboration improved a program (more ideas, fewer bugs 缺陷, wider testing 测试).

Worked example. Two students build a quiz app. Mei writes the scoring procedure while Tom reviews each line as she types; later Tom asks five classmates to try the app, and two of them find that a blank answer crashes it. How did collaboration help?

  1. Tom's review caught errors as they were typed (pair programming).
  2. The classmates are users with different habits; their tests found a case neither programmer had thought of, the blank answer.
  3. Each benefit is named and tied to the program: "more testers found the blank-answer crash" earns credit where "teamwork is good" does not.
词汇 训练
English 中文 拼音
collaborative/kəˈlæbrətɪv/ 协作 xié zuò
perspectives/pəˈspektɪvz/ 视角 shì jiǎo
consensus building 达成共识 dá chéng gòng shí
Pair programming/peə ˈprəʊɡræmɪŋ/ 结对编程 jié duì biān chéng
bug/bʌɡ/ 缺陷 quē xiàn
testing/ˈtestɪŋ/ 测试 cè shì
1.2

程序的功能与目的

教学大纲

持久理解 (CRD-2): 开发者采用以用户为中心、融入实施/反馈循环且为实验和冒险留出充分空间的迭代设计过程来创建和创新。

学习目标 CRD-2.A: 描述计算创新的目的。[技能 1.A]

  • CRD-2.A.1 计算创新的目的是通过创造性表达来解决问题或追求兴趣。
  • CRD-2.A.2 对计算创新目的的理解能够提升开发者开发该计算创新的能力。

学习目标 CRD-2.B: 解释程序或代码段的功能机制。[技能 4.A]

  • CRD-2.B.1 程序是由一系列程序语句组成的集合,在计算机运行时执行特定任务。程序通常被称为软件。
  • CRD-2.B.2 代码段是程序的一部分,由一系列程序语句组成。
  • CRD-2.B.3 程序需要能够处理多种输入和情况。
  • CRD-2.B.4 程序的行为是指程序在执行期间的运作方式,通常通过用户与其交互的方式来描述。
  • CRD-2.B.5 可以从宏观上描述程序做什么,也可以更详细地描述程序做了什么以及程序语句是如何实现这一功能的。

学习目标 CRD-2.C: 识别程序的输入。[技能 3.A]

  • CRD-2.C.1 程序输入是发送给计算机供程序处理的数据。输入可以呈现多种形式,例如触觉、音频、视觉或文本。
  • CRD-2.C.2 事件与动作相关联,并为程序提供输入数据。
  • CRD-2.C.3 按下按键、点击鼠标、启动程序或其他任何影响执行流程的已定义动作发生时,都会产生事件。
  • CRD-2.C.4 输入通常会决定程序产生的输出。
  • CRD-2.C.5 在事件驱动编程中,程序语句是在被触发时执行,而非通过顺序控制流执行。
  • CRD-2.C.6 输入可以来自用户或其他程序。

学习目标 CRD-2.D: 识别程序产生的输出。[技能 3.A]

  • CRD-2.D.1 程序输出是程序发送给设备的任何数据。程序输出可以呈现多种形式,例如触觉、音频、视觉或文本。
  • CRD-2.D.2 程序输出通常基于程序的输入或先前状态(例如内部值)。

来源:College Board AP 课程与考试说明

English

Every program is written for a purpose 目的 – it solves a problem or pursues an interest. A program takes input 输入, processes it, and produces output 输出. Inputs can come from a user, a device, a file, or another program; outputs can be visual, audible, textual, or a signal to a device. Being able to state a program's purpose, and describe its inputs and outputs clearly, is a core skill (and part of the Create performance task).

Every program decomposes into input, processing, and output
Every program decomposes into input, processing, and output
Every program follows the input-processing-output model
Every program follows the input-processing-output model

Worked example. A step-counter app reads movement from the phone's motion sensor, counts steps, and shows the day's total and a badge when the user passes 10,000.

Ask Answer
Purpose: why it exists to help users stay active by tracking their walking
Function: what it does counts steps and compares the total with a goal
Input readings from the motion sensor; the user's goal
Output the step total on screen; a badge at 10,000

A common mistake is to give the function as the purpose: "it counts steps" says what the program does, not the problem it solves.

探索

探索输入 → 处理 → 输出模型

逐步理解IPO模型。每个程序接收一些输入,按照其指令对其进行处理,然后生成输出——沿流程追踪一个天气应用程序示例。

词汇 训练
English 中文 拼音
purpose/ˈpɜːpəs/ 目的 mù dì
input/ˈɪnpʊt/ 输入 shū rù
output/ˈaʊtpʊt/ 输出 shū chū
1.3

程序设计与开发

教学大纲

持久理解 (CRD-2): 开发者采用以用户为中心的迭代设计过程进行创建和创新,该过程包含实施/反馈循环,并为实验和承担风险留出了充足的空间。

学习目标 CRD-2.E: 使用开发过程开发一个程序。[技能 1.B]

  • CRD-2.E.1 开发过程可以是有序且有意的,也可以是探索性的。
  • CRD-2.E.2 存在多种开发过程。在开发程序时,通常使用以下阶段:
    • 调查与反思
    • 设计
    • 原型制作
    • 测试
  • CRD-2.E.3 迭代式的开发过程需要根据过程中的反馈、测试或反思进行完善和修订。这可能意味着需要重新回到过程的早期阶段。
  • CRD-2.E.4 增量式开发过程是将问题分解为更小的部分,并确保每个部分正常工作后再将其添加到整体中。

学习目标 CRD-2.F: 设计一个程序及其用户界面。[技能 1.B]

  • CRD-2.F.1 程序的设计 incorporates 调查以确定其需求。(注:原文此处应为 "incorporates investigation",即“包含调查”)
  • CRD-2.F.2 开发过程中的调查有助于理解和识别程序约束,以及程序使用者的关注点和兴趣。
  • CRD-2.F.3 执行调查的一些方法如下:
    • 通过问卷调查收集数据
    • 用户测试
    • 访谈
    • 直接观察
  • CRD-2.F.4 程序需求描述程序的功能,可能包括程序必须提供的用户交互描述。
  • CRD-2.F.5 程序的规格说明定义了程序的需求。
  • CRD-2.F.6 在开发过程中,设计阶段概述了如何实现给定的程序规格说明。
  • CRD-2.F.7 程序的设计阶段可能包括:
    • 头脑风暴
    • 规划和故事板制作
    • 将程序组织成模块和功能组件
    • 创建代表用户界面布局的图表
    • 制定程序的测试策略

学习目标 CRD-2.G: 通过编写文档来描述代码段或程序的目的。[技能 4.A]

  • CRD-2.G.1 程序文档是对代码段、事件、过程或程序的功能及其开发方式的书面描述。
  • CRD-2.G.2 注释是写入程序中供人阅读的一种程序文档形式,不会影响程序的运行方式。
  • CRD-2.G.3 程序员应在整个开发过程中对程序进行文档记录。
  • CRD-2.G.4 无论是单独工作还是在协作编程环境中,程序文档都有助于开发和维护正确的程序。
  • CRD-2.G.5 并非所有编程环境都支持注释,因此可能需要其他文档记录方法。

学习目标 CRD-2.H: 承认来自其他来源的代码段。[技能 1.C]

  • CRD-2.H.1 承认任何合作开发或由其他来源开发的代码段是很重要的。
  • CRD-2.H.2 对他人编写并在程序中使用的一个或多个代码段的承认可以在程序文档中进行。承认应包含来源或原作者的姓名。

来源:College Board AP 课程与考试说明

English
A programmer debugging at a multi-monitor workstation — iterative design and testing
A programmer debugging at a multi-monitor workstation — iterative design and testing

Programs are built through an iterative 迭代的 process, not in one straight line: investigate the problem and users, design (often with a diagram 图示 or written plan), implement 实现 in code, and test – then repeat. A large problem is broken into smaller pieces (decomposition 分解). Comments 注释 and clear naming document the design so others (and your future self) can understand it. Development is incremental 增量的 – build and test a small piece, then add the next.

The stages of program development, with testing feeding back to fix and refine
The stages of program development, with testing feeding back to fix and refine
Software is built by an iterative, incremental development process
Software is built by an iterative, incremental development process

Investigating what users actually need

Before any code is written, the developer investigates the problem and the people who will use the program. Three ways to do that:

  • surveys 调查问卷 sent to potential users, which collect data from many people quickly;
  • interviews 访谈 and direct observation 观察 of users doing the task by hand;
  • studying existing solutions to see what already works and what frustrates people.

The findings are turned into a design. Two artefacts do that: a program requirements 程序需求 list saying exactly what the program must do, and diagrams representing the layout of the user interface 用户界面 — sketches showing which controls appear where, and what each one does when used. Designing the interface on paper first is cheaper than discovering after coding that the buttons are in the wrong place.

Events, and programs that wait

Not every program runs straight through from top to bottom. An event 事件 is generated when a key is pressed, a mouse is clicked, a program is started, or any other defined action occurs — and an event changes the flow of execution 执行流程: the program pauses what it was doing and runs the code attached to that event, called an event handler 事件处理程序.

This is why a program with a graphical interface can appear to be doing nothing: it is waiting for the next event. The order in which those events arrive is decided by the user, not by the programmer, so the same program can run its blocks in a different order each time it is used.

探索

循环执行迭代开发流程

开发是迭代式的——你重复各个阶段,在每次循环中对程序进行小幅改进。沿着循环步骤走,注意它会回到起点,而不是在一次运行后结束。

词汇 训练
English 中文 拼音
iterative/ˈɪtərətɪv/ 迭代的 dié dài de
diagram 图示 tú shì
implement 实现 shí xiàn
decomposition/ˌdiːkɒmpəˈzɪʃn/ 分解 fēn jiě
Comments/ˈkɒments/ 注释 zhù shì
incremental/ˌɪŋkrɪˈmentl/ 增量的 zēng liàng de
surveys/ˈsɜːveɪz/ 调查问卷 diào chá wèn juǎn
interview/ˈɪntəvjuː/ 访谈 fǎng tán
observation/ɒbzəˈveɪʃn/ 观察 guān chá
program requirements 程序需求 chéng xù xū qiú
user interface/ˈjuːzə ˈɪntəfeɪs/ 用户界面 yòng hù jiè miàn
event/ɪˈvent/ 事件 shì jiàn
flow of execution 执行流程 zhí xíng liú chéng
event handler/ɪˈvent ˈhændlə/ 事件处理程序 shì jiàn chǔ lǐ chéng xù
1.4

识别与纠正错误

教学大纲

持久性理解 (CRD-2): 开发者采用以用户为中心的迭代设计过程进行创造和创新,该过程包含实现/反馈循环,并为实验和冒险留出了充足的空间。

学习目标 CRD-2.I: 针对算法或程序中的错误: a. 识别错误。[技能 4.C] b. 纠正错误。[技能 4.C]

  • CRD-2.I.1 逻辑错误 是算法或程序中的错误,会导致其表现不正确或出乎意料。
  • CRD-2.I.2 语法错误 是程序中的错误,表现为未遵循编程语言的规则。
  • CRD-2.I.3 运行时错误 是在程序执行期间发生的程序错误。编程语言定义了它们各自的运行时错误。
  • CRD-2.I.4 溢出错误 是当计算机试图处理超出定义值范围之外的数字时发生的错误。
  • CRD-2.I.5 以下方法可有效发现并纠正错误:
    • 测试用例
    • 手动追踪
    • 可视化
    • 调试器
    • 添加额外的输出语句

学习目标 CRD-2.J: 识别可用于检查算法或程序正确性的输入及其对应的预期输出或行为。[技能 4.C]

  • CRD-2.J.1 在开发过程中,测试 使用定义的输入来确保算法或程序产生预期的结果。程序员利用测试结果来修订其算法或程序。
  • CRD-2.J.2 用于测试程序的定义输入应展示不同预期结果,这些结果位于输入数据极值(最小值和最大值)处或其附近。
  • CRD-2.J.3 程序需求对于确定合适的测试定义输入至关重要。

来源:College Board AP 课程与考试说明

English

A bug is an error in a program; debugging 调试 is finding and fixing it. Three kinds:

A trace table records each variable's value as the program runs, to find bugs
A trace table records each variable's value as the program runs, to find bugs
  • a syntax error 语法错误 breaks the language's rules, so the program will not run;
  • a runtime error 运行时错误 crashes the program while it runs (e.g. dividing by zero);
  • a logic error 逻辑错误 lets it run but gives the wrong result.

Find bugs by testing with different inputs, adding print statements 打印语句 to see values, and hand-tracing 手动跟踪 the code. Choose the test inputs deliberately: they should demonstrate the different expected outcomes at or just beyond the extremes — the minimum and maximum values the program should accept, and a value just outside each of them. A program that works on ordinary data very often fails on an empty list, a zero, or a value one past the end of a range, so those are the inputs worth trying first. Fixing one bug at a time and re-testing is the reliable method.

Exam skill: be able to name the type of an error and describe a testing strategy that would catch it – a recurring multiple-choice and Create-task theme.

Three kinds of programming error: syntax, logic, and runtime
Three kinds of programming error: syntax, logic, and runtime

Worked example. A program meant to print the average of two numbers instead runs avg = a + b / 2. Tracing the order of operations 运算顺序, / runs before +, so it computes $a+\tfrac{b}{2}$ rather than the average. Add parentheses to fix it: avg = (a + b) / 2. Testing with $a=4,\ b=6$ confirms the fix — the buggy line gives $4+3=7$, the corrected line gives $\tfrac{10}{2}=5$. Testing with known inputs is exactly how you find and confirm a logic error.

探索

追踪猜谜游戏逻辑,找出逻辑错误

拖动猜测值,观察哪个分支被执行。逻辑错误会将相同的猜测值送入错误的分支——程序仍然运行,但会输出错误的消息。此处的秘密数字是 50。

词汇 训练
English 中文 拼音
debugging/ˈdiːbʌɡɪŋ/ 调试 tiáo shì
syntax error/ˈsɪntæks ˈerə/ 语法错误 yǔ fǎ cuò wù
runtime error/ˈrʌntaɪm ˈerə/ 运行时错误 yùn xíng shí cuò wù
logic error/ˈlɒdʒɪk ˈerə/ 逻辑错误 luó jí cuò wù
print statement 打印语句 dǎ yìn yǔ jù
hand-tracing 手动跟踪 shǒu dòng gēn zōng
order of operations/ˈɔːdə ɒv ˌɒpəˈreɪʃnz/ 运算顺序 yùn suàn shùn xù
1.4

考试技巧

English
  • Assessment includes multiple-choice questions and the Create component, with written responses on the AP exam. Explain your reasoning clearly, not just your result.
  • Know the benefits of collaboration and how diverse perspectives reduce bias in a program.
  • Use precise vocabulary (iterative development, program requirements) when you describe a design process.
  • Give and take feedback 反馈 constructively; credit collaborators and sources.
  • Break a large problem into smaller modules that a team can build in parallel.
词汇 训练
English 中文 拼音
feedback/ˈfiːdbæk/ 反馈 fǎn kuì

该知识点的互动课程

逐步完成,配合即时检查练习。

历年真题

更多 AP 计算机科学原理 知识点

登录或创建账户

IGCSE, A-Level & AP