Software Development Process软件开发流程
Professional software is not written in one burst of inspiration — it is built through a disciplined life cycle (SDLC) that transforms a vague wish into a working, documented, maintainable product. This guide walks every phase from requirements gathering through design, implementation, testing, documentation, and maintenance, then introduces the collaboration tools — version control (Git) and code review — that make team software development work. Pseudocode and flowcharts appear in the design section; code examples are in Python but the concepts apply to any language.专业软件不是灵感爆发的产物,而是通过严格的生命周期(SDLC,软件开发生命周期)将模糊的需求(requirements,需求)转化为可工作、有文档、可维护产品的结果。本指南逐一讲解需求收集、设计(design,设计)、实现(implementation,实现)、测试(testing,测试)、文档(documentation,文档)和维护(maintenance,维护)各阶段,再介绍版本控制(version control,版本控制,Git)和代码审查等协作工具。设计节包含伪代码和流程图;代码示例用 Python,但概念适用于任何语言。
How to use this guide如何使用本指南
The software development life cycle is covered in all four curricula, but with different emphasis. Ontario ICS3U strand B4 names all seven SDLC phases verbatim and requires a formal test plan — that coverage aligns with §1, §2, and §5. BC Computer Programming 11 frames the entire programming course around the design cycle, making §3 (design) and §7 (collaboration) its core. Alberta builds SDLC skills into every module's outcome structure rather than one dedicated unit. US CSTA 3B-AP-16/22 and AP CSP Big Idea 1 (CRD) emphasise the iterative, collaborative nature of development — matching §7. The table below tells you which sections are core for your curriculum right now.软件开发生命周期在四套大纲中均有覆盖,但侧重点不同。安大略 ICS3U B 单元 B4 逐字命名全部七个 SDLC 阶段,并要求正式测试计划——这对应 §1、§2 和 §5。BC Computer Programming 11 将整个编程课程围绕设计周期展开,使 §3(设计)和 §7(协作)成为核心。阿尔伯塔将软件开发技能嵌入每个模块的结果结构中,而非单独的一个单元。美国 CSTA 3B-AP-16/22 和 AP CSP 大概念 1(CRD)强调开发的迭代性和协作性——对应 §7。下表告诉你当前哪些节属于你大纲的核心内容。
| If you are in…如果你在… | Focus on these sections重点学习 | Defer / lighter可推迟 / 减负 | Source依据 |
|---|---|---|---|
| 🇺🇸 US CSTA / AP CSP美国 CSTA / AP CSP | §1 (SDLC overview), §5 (testing — CRD-2.J), §7 (collaboration — CRD-1.A/B). AP CSP Big Idea 1 maps directly to §2–§5 (design, prototyping, testing, debugging). CSTA 3B-AP-22 (modify and iterate) maps to §6 (maintenance).§1(SDLC 概览)、§5(测试——CRD-2.J)、§7(协作——CRD-1.A/B)。AP CSP 大概念 1 直接对应 §2–§5(设计、原型制作、测试、调试)。CSTA 3B-AP-22(修改与迭代)对应 §6(维护)。 | Formal project management (§2 Gantt/scope docs) is AP CSP-lighter; emphasised more in Ontario ICS4U.正式项目管理(§2 甘特图/范围文档)在 AP CSP 中较轻;安大略 ICS4U 更为强调。 | CSTA K-12 and AP CSP — CSTA 3B-AP-16, 3B-AP-22; AP CSP Big Idea 1 (CRD) topics 1.1–1.4— CSTA 3B-AP-16、3B-AP-22;AP CSP 大概念 1(CRD)主题 1.1–1.4 |
| 🇨🇦 ON Grade 11 — ICS3U安大略 11 年级 — ICS3U | §1 through §6 in full — ICS3U B4 explicitly names all seven SDLC phases. §3 (UML tools — B2.4), §5 (test plan — B4.4), §6 (documentation). ICS4U B1.7 adds version control (§7).§1 至 §6 完整学习——ICS3U B4 明确命名全部七个 SDLC 阶段。§3(UML 工具——B2.4)、§5(测试计划——B4.4)、§6(文档)。ICS4U B1.7 增加版本控制(§7)。 | Full Gantt/PERT project management in §2 is ICS4U strand B1.4 (Grade 12 honors stream).§2 中的完整甘特图/PERT 项目管理属 ICS4U B 单元 B1.4(12 年级荣誉流)。 | ON/BC Computer Studies 11-12 — ICS3U B2.4, B4, B4.1, B4.4; ICS4U B1, B1.4, B1.7— ICS3U B2.4、B4、B4.1、B4.4;ICS4U B1、B1.4、B1.7 |
| 🇨🇦 BC — CP11 / CP12BC — CP11 / CP12 | §1 (design cycle Big Idea), §3 (design), §5 (test cases — CP11 verbatim), §7 (pair programming, collaboration tools — CP11/CP12 verbatim). CP12 adds standardized documentation (§6) and debugging tools.§1(设计周期大概念)、§3(设计)、§5(测试用例——CP11 原文)、§7(结对编程、协作工具——CP11/CP12 原文)。CP12 增加标准化文档(§6)和调试工具。 | Formal SDLC phase labelling (§1) is more Ontario/CSTA than BC; BC frames it through the design cycle Big Idea rather than a phase checklist.正式的 SDLC 阶段标注(§1)更多属于安大略/CSTA 的风格,而非 BC;BC 通过设计周期大概念而非阶段清单来框架化此内容。 | ON/BC Computer Studies 11-12 — BC CP11 design cycle / test cases / pair programming; CP12 documentation / debugging tools— BC CP11 设计周期/测试用例/结对编程;CP12 文档/调试工具 |
| 🇨🇦 AB — CSE Project modules阿尔伯塔 — CSE 项目模块 | §1 (SDLC framing — built into every module), §4 (implementation — CSE1110 outcome 2.1), §5 (testing — CSE1110 outcome 3.1). The iterative/incremental framing from CSE3120 outcome 2.2 and 3.1 underpins §1 and §7.§1(SDLC 框架——嵌入每个模块)、§4(实现——CSE1110 结果 2.1)、§5(测试——CSE1110 结果 3.1)。CSE3120 结果 2.2 和 3.1 的迭代/增量框架支撑 §1 和 §7。 | Dedicated project-management documents (scope doc, Gantt chart) sit in the CSE Project modules (CSE1910/2910/3910); they are handled as separate CTS credits.专项项目管理文档(范围文档、甘特图)在 CSE 项目模块(CSE1910/2910/3910)中;它们作为独立的 CTS 学分处理。 | Alberta CTS Computing Science — CSE1110 outcomes 2.1, 3.1; CSE3120 outcomes 2.2, 3.1; CSE Project A/B/C/D descriptions— CSE1110 结果 2.1、3.1;CSE3120 结果 2.2、3.1;CSE 项目 A/B/C/D 描述 |
Once you have located your row, use the two cards below to calibrate your study pace.找到所在行后,用下面两张卡片决定推进速度。
Memorise three things: the seven SDLC phases in order (requirements, analysis, design, implementation, testing, documentation/deployment, maintenance); the three types of errors (syntax, logic, runtime); and what a test plan includes (scenario, input, expected output, actual output, pass/fail). Read every cram-cheat box. Skip the Git deep-dive in §7.背熟三件事:七个 SDLC 阶段的顺序(需求、分析、设计、实现、测试、文档/部署、维护);三种错误类型(语法、逻辑、运行时);测试计划包含的内容(场景、输入、预期输出、实际输出、通过/失败)。读每个速记框,跳过 §7 中的 Git 深入内容。
Always design before you implement: write requirements first, produce a design artifact (flowchart, pseudocode, or UML sketch), then write a test plan before touching a code editor. Ontario ICS3U B4.4 and AP CSP CRD-2.J both assess your ability to write test plans with expected outputs. AB CSE1110 outcome 3.1 requires testing for both success and failure. §7 version control is assessed in Ontario ICS4U B1.7 — know the four core Git commands.永远先设计再实现:先写需求,产出设计制品(流程图、伪代码或 UML 草图),然后在打开代码编辑器之前写好测试计划。安大略 ICS3U B4.4 和 AP CSP CRD-2.J 都考核你编写包含预期输出的测试计划的能力。AB CSE1110 结果 3.1 要求对成功和失败情况都进行测试。§7 版本控制在安大略 ICS4U B1.7 中被考核——掌握四个核心 Git 命令。
git init, git add, git commit, git push) and the branch-merge workflow. The Honors chip marks the going-deeper box covering branching strategies and pull-request code review. That box maps to Ontario ICS4U B1.7 (version control) and CSTA 3B-AP-20 ("Use version control systems … in a group software project"). For ICS3U / CSE1110 / AP CSP floor students, understanding what version control is and why it matters is the assessed level; you do not need to demonstrate Git commands in an exam.§7(协作与版本控制)从概念层面介绍 Git:四个命令(git init、git add、git commit、git push)和分支合并工作流。Honors 标记深入框,涵盖分支策略和拉取请求代码审查。该框对应安大略 ICS4U B1.7(版本控制)和 CSTA 3B-AP-20("在团队软件项目中使用版本控制系统……")。对于 ICS3U / CSE1110 / AP CSP 基础学生,理解版本控制是什么及其重要性是被评估的层次;考试中不需要演示 Git 命令。
The Software Development Life Cycle软件开发生命周期
- 1. Problem definition / Requirements1. 问题定义 / 需求 — what does the software need to do? Collect user needs, constraints, and success criteria.— 软件需要做什么?收集用户需求、约束条件和成功标准。
- 2. Analysis2. 分析 — study the requirements in detail; identify inputs, outputs, data flows, and edge cases.— 详细研究需求;确定输入、输出、数据流和边缘情况。
- 3. Design3. 设计 — produce design artifacts: flowcharts, pseudocode, UML diagrams, data structures, user interface sketches.— 产出设计制品:流程图、伪代码、UML 图、数据结构、用户界面草图。
- 4. Implementation (coding)4. 实现(编码) — translate the design into working code following coding standards.— 按照编码规范将设计转化为可运行的代码。
- 5. Testing5. 测试 — verify the code works correctly using a formal test plan (normal, boundary, and error cases).— 使用正式测试计划(正常、边界和错误情况)验证代码是否正确运行。
- 6. Documentation / Deployment6. 文档 / 部署 — write user and technical documentation; release the software to users.— 编写用户文档和技术文档;将软件发布给用户。
- 7. Maintenance7. 维护 — fix bugs that appear after release, add new features, and adapt the software as requirements change.— 修复发布后出现的错误,添加新功能,并随着需求变化调整软件。
Problem: a student team is tasked with building a homework-tracker app. Walk each SDLC phase for this project.问题:一个学生团队负责构建一个作业追踪应用。逐一分析该项目的每个 SDLC 阶段。
Requirements.需求。 Users (students) need to add tasks with due dates, mark tasks complete, and sort by urgency. Constraint: must work on mobile.用户(学生)需要添加带截止日期的任务、标记任务为已完成并按紧迫性排序。约束:必须在手机上运行。
Analysis.分析。 Inputs: task name, subject, due date. Outputs: sorted task list. Data: each task stores {name, subject, due_date, done}. Edge case: two tasks on the same due date.输入:任务名称、学科、截止日期。输出:已排序的任务列表。数据:每个任务存储 {name, subject, due_date, done}。边缘情况:两个任务的截止日期相同。
Design.设计。 Produce a flowchart for "add task," pseudocode for "sort by due date," and a simple UML class sketch showing Task attributes and methods.为"添加任务"画流程图,为"按截止日期排序"写伪代码,并画出显示 Task 属性和方法的简单 UML 类草图。
Implementation.实现。 Write Python/JavaScript code following the design. Apply coding standards: meaningful names, inline comments, no magic numbers.按照设计编写 Python/JavaScript 代码。遵循编码规范:有意义的命名、内联注释、无魔法数字。
Testing.测试。 Test plan: normal case (add 3 tasks, verify sort), boundary case (task due today), error case (no tasks in list — display "no tasks").测试计划:正常情况(添加 3 个任务,验证排序),边界情况(今天截止的任务),错误情况(列表中无任务——显示"无任务")。
Documentation/Deployment.文档/部署。 Write a README describing how to install and use the app. Deploy to the school server.编写描述如何安装和使用应用的 README。部署到学校服务器。
Maintenance.维护。 Users report that tasks with the same due date display in the wrong order — fix the sort comparator and increment the version number.用户报告截止日期相同的任务显示顺序不正确——修复排序比较器并更新版本号。
Going deeper — agile vs waterfall vs spiral深入 — 敏捷与瀑布与螺旋模型
CSTA 3B-AP-17 (verbatim): "Plan and develop programs for broad audiences using a software life cycle process. Processes could include agile, spiral, or waterfall." The three models differ in how rigidly they enforce phase order. Waterfall: each phase finishes completely before the next begins; changes are expensive. Agile: two-week sprints, each delivering a working increment; requirements can change between sprints. Spiral: each revolution of the spiral adds risk analysis before the next round of design/build/test. Ontario ICS4U B strand emphasises managing a real team project — in practice this means agile-style sprint planning. For exam purposes, being able to describe each model and name a tradeoff (waterfall: predictable but inflexible; agile: flexible but requires constant communication) is sufficient.CSTA 3B-AP-17(原文):"使用软件生命周期流程为广大受众规划和开发程序。流程可包括敏捷、螺旋或瀑布。"三种模型的区别在于阶段顺序的严格程度。瀑布:每个阶段完全完成后才开始下一个;变更代价高昂。敏捷:两周冲刺,每次交付一个可运行的增量;需求可在冲刺之间变化。螺旋:每圈螺旋在下一轮设计/构建/测试之前增加风险分析。安大略 ICS4U B 单元强调管理真实团队项目——实际上意味着敏捷式冲刺规划。对于考试来说,能够描述每种模型并指出一个权衡(瀑布:可预测但不灵活;敏捷:灵活但需要持续沟通)就足够了。
Requirements and Planning需求与规划
- Functional requirements功能性需求 — what the system must do. "The user must be able to log in with a username and password." Expressed as user stories or use cases.— 系统必须做什么。"用户必须能够用用户名和密码登录。"用用户故事或用例表达。
- Non-functional requirements非功能性需求 — how the system must perform. "The login must complete in under 2 seconds." Covers performance, security, accessibility, and maintainability.— 系统必须如何运行。"登录必须在 2 秒内完成。"涵盖性能、安全性、无障碍性和可维护性。
Problem: write a numbered requirements list for a program that reads five assignment scores and outputs a letter grade.问题:为一个读取五个作业成绩并输出字母等级的程序编写编号需求列表。
Functional requirements.功能性需求。
FR-1: The program shall accept exactly 5 numeric scores as input.
-- 程序应接受恰好 5 个数字成绩作为输入。
FR-2: The program shall compute the arithmetic mean of the 5 scores.
-- 程序应计算 5 个成绩的算术平均值。
FR-3: The program shall output a letter grade (A/B/C/D/F)
based on the mean (A>=90, B>=80, C>=70, D>=60, F otherwise).
-- 程序应根据平均值输出字母等级(A>=90, B>=80, C>=70, D>=60, 否则 F)。
Non-functional requirements.非功能性需求。
NFR-1: Scores outside [0, 100] shall trigger an error message, not a crash.
-- 范围 [0, 100] 之外的成绩应触发错误消息,而非程序崩溃。
NFR-2: The program shall run in Python 3.8+ with no external libraries.
-- 程序应在 Python 3.8+ 中运行,无需外部库。
Notice that every requirement is numbered (so test cases can reference them: "Test for FR-3, boundary case score=90") and testable.注意每个需求都有编号(以便测试用例可以引用它们:"FR-3 的测试,边界情况 score=90")且可测试。
Going deeper — user stories and acceptance criteria (Agile)深入 — 用户故事和验收标准(敏捷)
In Agile development, requirements are often written as user stories in the format: "As a [user role], I want [action] so that [benefit]." Example: "As a student, I want to mark a task complete so that I can track my progress." Each story has acceptance criteria — the conditions that must be true for the story to be done: "Given a list of 3 tasks, when I click 'Mark complete' on task 2, then task 2 appears with a strikethrough and moves to the bottom of the list." This Given/When/Then format (also called Gherkin) is used in professional test automation. AP CSP CRD-2.A Learning Objective states: "Describe the purpose of a computing innovation." User stories are one structured way to capture that purpose from the user's perspective.在敏捷开发中,需求通常以用户故事的格式编写:"作为 [用户角色],我想要 [操作],以便 [获益]。"示例:"作为一名学生,我想要标记任务为已完成,以便我可以追踪进度。"每个故事都有验收标准——故事完成所必须满足的条件:"给定一个包含 3 个任务的列表,当我点击任务 2 的'标记为完成'时,任务 2 应显示删除线并移至列表底部。"这种给定/当/则格式(也称 Gherkin)在专业测试自动化中使用。AP CSP CRD-2.A 学习目标指出:"描述计算创新的目的。"用户故事是从用户角度捕获该目的的一种结构化方式。
Design (Pseudocode, Flowcharts, UML Intro)设计(伪代码、流程图、UML 入门)
- Pseudocode伪代码 — describe the logic of a single algorithm in structured English. Best for capturing loop/decision logic before coding. Uses keywords:
INPUT,OUTPUT,IF/ELSE,WHILE,FOR,SET x TO.— 用结构化英语描述单个算法的逻辑。最适合在编码前捕获循环/判断逻辑。使用关键字:INPUT、OUTPUT、IF/ELSE、WHILE、FOR、SET x TO。 - Flowchart流程图 — visual representation of algorithm control flow. Oval = Start/End; Rectangle = Process; Diamond = Decision (two exits: YES/NO); Parallelogram = Input/Output. BC CP11 verbatim: "tools to aid in the development process."— 算法控制流的可视化表示。椭圆 = 开始/结束;矩形 = 处理;菱形 = 判断(两个出口:是/否);平行四边形 = 输入/输出。BC CP11 原文:"辅助开发过程的工具。"
- UML Class Diagram (intro)UML 类图(入门) — shows the attributes and methods of a class in a box with three sections: class name (top), attributes (middle), methods (bottom). Ontario ICS3U B2.4 lists "UML" as an accepted design tool.— 在三节盒子中显示类的属性和方法:类名(顶部)、属性(中部)、方法(底部)。安大略 ICS3U B2.4 将"UML"列为公认的设计工具。
Problem: produce three design artifacts for a simple username/password login function.问题:为简单的用户名/密码登录功能产出三种设计制品。
1. Pseudocode.1. 伪代码。
INPUT username, password
IF username == "admin" AND password == "pass123" THEN
OUTPUT "Login successful"
ELSE
OUTPUT "Invalid credentials"
END IF
-- 以上:如果用户名为 "admin" 且密码为 "pass123",输出"登录成功",否则输出"无效凭据"。
2. Flowchart (text description).2. 流程图(文字描述)。
Oval "START" → Parallelogram "Input username, password" → Diamond "username='admin' AND password='pass123'?" → YES: Parallelogram "Output: Login successful" → Oval "END"; NO: Parallelogram "Output: Invalid credentials" → Oval "END".椭圆"开始"→ 平行四边形"输入用户名、密码"→ 菱形"username='admin' 且 password='pass123'?"→ 是:平行四边形"输出:登录成功"→ 椭圆"结束";否:平行四边形"输出:无效凭据"→ 椭圆"结束"。
3. UML Class Diagram (intro level).3. UML 类图(入门级)。
+------------------+
| LoginSystem | <-- class name 类名
+------------------+
| - username: str | <-- attributes (- means private)
| - password: str | 属性(- 表示私有)
+------------------+
| + login(): bool | <-- methods (+ means public)
| + logout(): void | 方法(+ 表示公有)
+------------------+
The UML box shows what data the class stores (attributes) and what actions it can perform (methods). This is the design blueprint; the Python implementation follows from it.UML 盒子显示类存储哪些数据(属性)以及可以执行哪些操作(方法)。这是设计蓝图;Python 实现由此而来。
Implementation and Coding Standards实现与编码规范
- Meaningful names有意义的命名 — variable and function names should say what they store/do.
student_countis good;xis bad (unless it is a local loop counter).— 变量和函数名应说明其存储/操作的内容。student_count是好的;x是不好的(除非是局部循环计数器)。 - Inline comments内联注释 — explain the why, not the what.
# decrement to convert from 1-indexed to 0-indexedis useful;# add 1is useless. BC CP11 verbatim: "inline commenting to document source code."— 解释为什么,而非是什么。# 减去 1 以从 1 索引转换为 0 索引是有用的;# 加 1是无用的。BC CP11 原文:"内联注释记录源代码。" - No magic numbers无魔法数字 — replace hard-coded literals with named constants. Instead of
if score >= 90scattered everywhere, useA_THRESHOLD = 90once at the top.— 用命名常量替换硬编码的字面量。不要在各处写if score >= 90,而是在顶部一次性定义A_THRESHOLD = 90。 - Consistent indentation and style一致的缩进和风格 — use 4 spaces per indent level (Python PEP 8), consistent brace style, and a style guide shared by the team. Ontario ICS3U B2.4 requires "industry-standard" tool use.— 每个缩进级别使用 4 个空格(Python PEP 8),一致的花括号风格,以及团队共享的风格指南。安大略 ICS3U B2.4 要求使用"行业标准"工具。
Problem: the following Python code works but violates coding standards. Identify the violations and rewrite it.问题:以下 Python 代码可以运行,但违反了编码规范。识别违规之处并重写。
Original (bad) code.原始(糟糕的)代码。
x = float(input("enter: "))
y = (x*9/5)+32
if y>212:
print("boiling") # hot
Violations identified.识别的违规之处。
- Poor names:
x,y. Magic number:212. Useless comment:# hotjust repeats what the print says. Inconsistent indentation (2 spaces, not 4).命名不佳:x、y。魔法数字:212。无用注释:# hot只是重复了 print 的内容。缩进不一致(2 个空格,而非 4 个)。
Refactored (good) code.重构后(好的)代码。
BOILING_POINT_F = 212 # water boils at 212°F at sea level
# 水在海平面 212°F 沸腾
celsius = float(input("Enter temperature in Celsius: "))
fahrenheit = (celsius * 9 / 5) + 32
# Check if temperature exceeds boiling point (relevant for lab safety)
# 检查温度是否超过沸点(与实验室安全相关)
if fahrenheit > BOILING_POINT_F:
print("Warning: above boiling point")
The refactored version has meaningful names, a named constant, a useful comment explaining the why, and consistent 4-space indentation. The logic is identical — only the readability changed.重构后的版本具有有意义的名称、命名常量、解释为什么的有用注释以及一致的 4 个空格缩进。逻辑完全相同——只有可读性发生了变化。
90 in if score >= 90 is a magic number — it should be A_THRESHOLD = 90 at the top of the file. Option B already does this correctly (it is a named constant). Options A and C use variables/range() appropriately.魔法数字是上下文中含义不明显的硬编码字面量。if score >= 90 中的 90 是魔法数字——应该在文件顶部定义 A_THRESHOLD = 90。选项 B 已经正确地这样做了(它是命名常量)。选项 A 和 C 适当地使用了变量/range()。90 for a grade threshold is a magic number — its meaning requires context. Replacing it with A_THRESHOLD = 90 (option B style) is the fix.魔法数字是无法解释的硬编码字面量。成绩阈值的 90 是魔法数字——其含义需要上下文。用 A_THRESHOLD = 90(选项 B 风格)替换它是修复方法。Going deeper — code review as a quality gate深入 — 代码审查作为质量门
CSTA 3B-AP-23 (verbatim): "Evaluate key qualities of a program through a process such as a code review." A code review is a structured process in which a colleague reads your code before it is merged into the main codebase. Reviewers check: do variable names explain intent? Are all edge cases handled? Is there dead code? Are comments accurate? In professional teams this is enforced through a pull-request workflow in Git — code cannot merge until at least one reviewer approves it. Ontario ICS4U B1 (project management) and BC CP12 "collaboration tools for programming" both implicitly require this practice. For a solo school project, a self-review checklist (naming, comments, constants, edge cases) achieves the same quality improvement.CSTA 3B-AP-23(原文):"通过代码审查等过程评估程序的关键质量。"代码审查是一个结构化过程,同事在代码合并到主代码库之前阅读你的代码。审查者检查:变量名是否解释了意图?是否处理了所有边缘情况?是否有死代码?注释是否准确?在专业团队中,这通过 Git 的拉取请求工作流强制执行——在至少一个审查者批准之前,代码无法合并。安大略 ICS4U B1(项目管理)和 BC CP12"编程协作工具"都隐含地要求这种做法。对于单独的学校项目,自我审查清单(命名、注释、常量、边缘情况)可实现相同的质量改进。
Testing and Debugging测试与调试
- Test scenario测试场景 — a short description of what is being tested ("Normal login with correct password").— 被测内容的简短描述("使用正确密码正常登录")。
- Input data输入数据 — the specific values used (username="admin", password="pass123").— 使用的具体值(username="admin",password="pass123")。
- Expected output预期输出 — what the program should produce if correct ("Login successful").— 正确时程序应产生的内容("登录成功")。
- Actual output + Pass/Fail实际输出 + 通过/失败 — what the program actually produced, and whether it matches the expected output.— 程序实际产生的内容,以及是否与预期输出匹配。
Write a 4-row test plan for a program that reads a score [0–100] and outputs a letter grade (A≥90, B≥80, C≥70, D≥60, F otherwise).为一个读取 [0–100] 范围内分数并输出字母等级(A≥90,B≥80,C≥70,D≥60,否则 F)的程序编写 4 行测试计划。
| Scenario场景 | Input输入 | Expected output预期输出 | Type类型 |
|---|---|---|---|
| Normal case — B grade正常情况——B 等级 | 85 | B | Normal正常 |
| Boundary — exact A threshold边界——恰好 A 阈值 | 90 | A | Boundary边界 |
| Boundary — one below A threshold边界——A 阈值下一分 | 89 | B | Boundary边界 |
| Error case — out of range错误情况——超出范围 | 150 | Error: score out of range错误:分数超出范围 | Error错误 |
Note: boundary cases at the exact threshold values (90, 80, 70, 60) are critical — they test whether >= is correctly used instead of >. An off-by-one here is a logic error.注意:恰好在阈值(90、80、70、60)处的边界情况至关重要——它们测试是否正确使用 >= 而非 >。这里的差一错误是逻辑错误。
if score > 90 instead of if score >= 90, which would classify 90 correctly but misclassify 89 as A. This is an off-by-one boundary error.程序运行不崩溃(不是语法或运行时错误),但产生错误答案——这是逻辑错误。可能的原因是 if score > 90 而非 if score >= 90,这会正确分类 90,但将 89 错误分类为 A。这是差一边界错误。Going deeper — automated testing and test-driven development Honors — ICS4U / CSE3120深入 — 自动化测试与测试驱动开发 荣誉 — ICS4U / CSE3120
In professional software development, test plans are executed by automated testing frameworks (Python's unittest, JavaScript's Jest, Java's JUnit). Each test case is a function that calls the code under test with specific inputs and asserts the output matches the expected value. Test-driven development (TDD) inverts the order: write the test first (which fails), then write the minimum code to make it pass, then refactor. CSTA 3B-AP-21 (verbatim): "Develop and use a series of test cases to verify that a program performs according to its design specifications." CSE3120 outcome 3.1 also requires iterative testing throughout implementation. For ICS3U floor students, a hand-written test plan table is the assessed skill; automated testing is the Grade-12/advanced extension.在专业软件开发中,测试计划由自动化测试框架执行(Python 的 unittest、JavaScript 的 Jest、Java 的 JUnit)。每个测试用例是一个函数,用特定输入调用被测代码并断言输出与预期值匹配。测试驱动开发(TDD)颠倒了顺序:先编写测试(失败),然后编写最少的代码使其通过,再重构。CSTA 3B-AP-21(原文):"开发和使用一系列测试用例来验证程序是否按照其设计规格运行。" CSE3120 结果 3.1 也要求在整个实现过程中进行迭代测试。对于 ICS3U 基础学生,手写测试计划表是被评估的技能;自动化测试是 12 年级/高级扩展。
Documentation and Maintenance文档与维护
- Inline / code comments内联 / 代码注释 — audience: future developers (including your future self). Explains non-obvious code decisions using
#or/* */. BC CP11 verbatim: "inline commenting to document source code." CP12 verbatim: "Standardized source code documentation."— 受众:未来的开发人员(包括未来的自己)。使用#或/* */解释非显而易见的代码决策。BC CP11 原文:"内联注释记录源代码。" CP12 原文:"标准化源代码文档。" - Technical documentation技术文档 — audience: developers maintaining the system. Includes API reference (what each function does, its parameters, return value), data-structure diagrams, and architecture overview.— 受众:维护系统的开发人员。包括 API 参考(每个函数的功能、参数、返回值)、数据结构图和架构概述。
- User documentation用户文档 — audience: end users. Explains how to install and use the software. Includes a README, user guide, and error-message explanations. Written in plain language, no code.— 受众:最终用户。解释如何安装和使用软件。包括 README、用户指南和错误消息说明。用简明语言编写,无代码。
Write a properly documented Python function for computing a letter grade, showing three levels of documentation.编写一个有适当文档的 Python 函数来计算字母等级,展示三个层次的文档。
# grade_calculator.py — Dingrui Scholars Grade Tool, v1.0
# Author: student team | Last updated: 2026-01
# License: MIT
# 成绩计算工具 — 模块说明:根据百分制分数返回字母等级
def compute_grade(score: float) -> str:
"""
Convert a numeric score (0-100) to a letter grade.
将百分制分数(0-100)转换为字母等级。
Parameters / 参数:
score (float): numeric score, must be in [0, 100]
百分制分数,必须在 [0, 100] 范围内
Returns / 返回:
str: letter grade "A", "B", "C", "D", or "F"
字母等级 "A", "B", "C", "D" 或 "F"
Raises / 异常:
ValueError: if score is outside [0, 100]
如果分数超出 [0, 100] 范围
"""
# Validate input before processing (NFR-1)
# 处理前验证输入(对应非功能性需求 NFR-1)
if not (0 <= score <= 100):
raise ValueError(f"Score {score} out of range [0, 100]")
# Grade thresholds — defined as constants to avoid magic numbers
# 成绩阈值——定义为常量以避免魔法数字
A_THRESHOLD, B_THRESHOLD = 90, 80
C_THRESHOLD, D_THRESHOLD = 70, 60
if score >= A_THRESHOLD:
return "A"
elif score >= B_THRESHOLD:
return "B"
elif score >= C_THRESHOLD:
return "C"
elif score >= D_THRESHOLD:
return "D"
else:
return "F"
The docstring (triple-quoted string) is the standard Python technical documentation format. Tools like Sphinx auto-generate HTML documentation from docstrings. The inline comments explain the why. The module header is the user-facing documentation for anyone reading the file.文档字符串(三引号字符串)是标准的 Python 技术文档格式。Sphinx 等工具从文档字符串自动生成 HTML 文档。内联注释解释为什么。模块头是面向任何阅读文件的人的用户文档。
Collaboration and Version Control (Git Intro)协作与版本控制(Git 入门)
git init— initialise a new Git repository in the current folder. Creates a hidden.gitdirectory that tracks all future changes.— 在当前文件夹中初始化一个新的 Git 仓库。创建一个隐藏的.git目录来追踪所有未来的更改。git add <file>— stage a file for the next commit (mark it as "ready to save").git add .stages all changed files at once.— 将文件暂存为下一次提交(标记为"准备保存")。git add .一次暂存所有更改的文件。git commit -m "message"— save a snapshot of all staged files with a descriptive message. Each commit is a permanent, retrievable checkpoint.— 用描述性消息保存所有暂存文件的快照。每次提交都是一个永久的、可检索的检查点。git push— upload local commits to a remote repository (e.g., GitHub). Enables team members to access your work.— 将本地提交上传到远程仓库(如 GitHub)。使团队成员能够访问你的工作。
A pair of students is building a grade calculator. Trace their Git workflow from start to submission.两名学生正在构建成绩计算器。追踪他们从开始到提交的 Git 工作流。
# Day 1: Student A sets up the repository
# 第 1 天:学生 A 创建仓库
git init grade-calc
cd grade-calc
# 创建 grade_calculator.py 并编写初始函数
git add grade_calculator.py
git commit -m "Add compute_grade() function with A/B/C/D/F thresholds"
git push origin main
# Day 2: Student B clones and adds tests
# 第 2 天:学生 B 克隆并添加测试
git clone https://github.com/team/grade-calc
# 编写 test_grade_calculator.py 测试文件
git add test_grade_calculator.py
git commit -m "Add test plan: normal, boundary, and error cases for compute_grade()"
git push origin main
# Day 3: Student A fixes a boundary bug found by the tests
# 第 3 天:学生 A 修复测试发现的边界错误
# 将 'score > 90' 修正为 'score >= 90'(差一错误)
git add grade_calculator.py
git commit -m "Fix off-by-one: change > to >= for A threshold (fixes test TC-2)"
git push origin main
Each commit message is specific: it says what changed and why. This makes the project history readable — anyone can understand the change log without opening each file. The commit message "fixes test TC-2" links the code change to the test plan row, closing the requirements → design → implement → test → fix loop.每条提交消息都很具体:它说明了更改了什么以及为什么。这使项目历史可读——任何人都可以在不打开每个文件的情况下理解变更日志。提交消息"fixes test TC-2"将代码更改与测试计划行关联起来,形成需求 → 设计 → 实现 → 测试 → 修复的完整闭环。
git commit -m "Add login function" do?git commit -m "Add login function" 做什么?git commit saves a permanent snapshot (checkpoint) of all staged files. The -m flag provides the commit message. Uploading to GitHub requires a separate git push command; marking files ready is git add; creating a repo is git init.git commit 保存所有暂存文件的永久快照(检查点)。-m 标志提供提交消息。上传到 GitHub 需要单独的 git push 命令;标记文件就绪是 git add;创建仓库是 git init。commit saves locally; push uploads to remote.Git 工作流:init → add(暂存)→ commit(快照)→ push(上传)。commit 本地保存;push 上传到远程。Going deeper — branching strategies and pull requests Honors — ICS4U B1.7 / CSTA 3B-AP-20深入 — 分支策略和拉取请求 荣誉 — ICS4U B1.7 / CSTA 3B-AP-20
CSTA 3B-AP-20 (verbatim): "Use version control systems, integrated development environments (IDEs), and collaborative tools and practices (code documentation) in a group software project." In professional teams, the workflow is: (1) create a feature branch from main (git checkout -b feature/login); (2) commit work on the feature branch; (3) open a pull request (PR) — a request to merge the feature branch into main; (4) teammates review the PR (checking for bugs, style, test coverage); (5) after approval, the branch is merged and deleted. This workflow prevents untested code from entering the main codebase. Ontario ICS4U B1.7 requires "proper version control" for managing a Grade-12 team project — the pull-request workflow is the industry-standard implementation of that requirement.CSTA 3B-AP-20(原文):"在团队软件项目中使用版本控制系统、集成开发环境(IDE)和协作工具及实践(代码文档)。"在专业团队中,工作流是:(1) 从 main 创建功能分支(git checkout -b feature/login);(2) 在功能分支上提交工作;(3) 开启拉取请求(PR)——合并功能分支到 main 的请求;(4) 队友审查 PR(检查错误、风格、测试覆盖率);(5) 批准后,合并并删除分支。这个工作流防止未经测试的代码进入主代码库。安大略 ICS4U B1.7 要求在 12 年级团队项目中"正确的版本控制"——拉取请求工作流是该要求的行业标准实现。
Exam Strategy and Common Pitfalls考试策略与常见陷阱
- Name and sequence all seven phases.命名并排序全部七个阶段。 Ontario ICS3U B4.1 names the phases explicitly. Examiners ask you to "identify which SDLC phase" a given activity belongs to. Know: Requirements → Analysis → Design → Implementation → Testing → Documentation/Deployment → Maintenance.安大略 ICS3U B4.1 明确命名各阶段。考官要求你"确定哪个 SDLC 阶段"某项活动属于。牢记:需求 → 分析 → 设计 → 实现 → 测试 → 文档/部署 → 维护。
- Waterfall vs Agile — one key tradeoff each.瀑布 vs 敏捷 — 各一个关键权衡。 Waterfall: predictable schedule but expensive to change. Agile: flexible but requires constant communication. CSTA 3B-AP-17 names both; know one advantage and one disadvantage of each.瀑布:进度可预测,但变更代价高昂。敏捷:灵活但需要持续沟通。CSTA 3B-AP-17 命名了两者;各知道一个优点和一个缺点。
- Functional vs non-functional.功能性 vs 非功能性。 Functional = what the system does. Non-functional = how it performs (speed, security, accessibility). A common exam question gives a requirement and asks you to classify it.功能性 = 系统做什么。非功能性 = 如何执行(速度、安全性、无障碍性)。常见的考试题给出一个需求,要求你分类它。
- Design artifact match.设计制品匹配。 Pseudocode/flowchart → algorithm logic. UML class diagram → object structure. Know which tool to use for which problem, citing ICS3U B2.4 if you need to justify tool choice.伪代码/流程图 → 算法逻辑。UML 类图 → 对象结构。了解哪种工具用于哪种问题,如果需要证明工具选择,引用 ICS3U B2.4。
- Name the error type precisely.精确命名错误类型。 Syntax: fails to parse. Logic: wrong answer, no crash. Runtime/semantic: crash during execution. Examiners expect the exact term. BC CP11 uses "logical or semantic" — treat runtime and semantic as equivalent for BC.语法:无法解析。逻辑:答案错误,无崩溃。运行时/语义:执行期间崩溃。考官期望准确的术语。BC CP11 使用"逻辑或语义"——对于 BC,将运行时和语义视为等同。
- Test plan: always write all three case types.测试计划:始终编写全部三种情况类型。 Normal, boundary, error/exception. Ontario B4.4 and AB CSE1110 1.7 both require testing for failure as well as success. A test plan with only normal cases will lose marks.正常、边界、错误/异常。安大略 B4.4 和 AB CSE1110 1.7 都要求对失败和成功情况都进行测试。只有正常情况的测试计划会失分。
- Three documentation audiences.三类文档受众。 Inline comments → developers. API/technical docs → developer-maintainers. User guide/README → end users. A common exam question describes a document and asks which audience it serves.内联注释 → 开发人员。API/技术文档 → 开发维护人员。用户指南/README → 最终用户。常见的考试题描述一份文档,要求说明它服务的受众。
- Four core Git commands in order.四个核心 Git 命令的顺序。
git init→git add→git commit→git push. Know what each command does. ICS4U B1.7 may ask you to describe version control; knowing these four commands gives you concrete, citable specifics.git init→git add→git commit→git push。了解每个命令的作用。ICS4U B1.7 可能要求你描述版本控制;了解这四个命令为你提供具体、可引用的细节。
Flashcards闪卡
Practice Quiz综合测验
total_enrolled_students is the most descriptive — it tells any developer exactly what it stores without needing a comment. Coding standards require meaningful names. "students" is reasonable but "total" clarifies it is a count, not a list. "x" and "n" are meaningless as variable names for this purpose.total_enrolled_students 是最具描述性的——它准确告诉任何开发人员它存储的内容,无需注释。编码规范要求有意义的命名。"students"合理,但"total"澄清了它是一个计数,而非列表。"x"和"n"作为此目的的变量名毫无意义。git push uploads local commits to the remote repository. git commit saves a snapshot locally; git add stages files; git init creates a new repository. The workflow is: init → add → commit → push.git push 将本地提交上传到远程仓库。git commit 在本地保存快照;git add 暂存文件;git init 创建新仓库。工作流程是:init → add → commit → push。Readiness Checklist准备就绪清单
Tick each item when you can do it cold, without notes, on a first attempt.能在无笔记、首次尝试下完成,再勾选每一项。
- Name all seven SDLC phases in order and give a concrete example of one activity that happens in each phase for a simple school app project. 🇨🇦 ON ICS3U B4.1 / 🇺🇸 CSTA 3B-AP-17按顺序命名全部七个 SDLC 阶段,并为简单学校应用项目举出每个阶段发生的一项活动的具体例子。🇨🇦 ON ICS3U B4.1 / 🇺🇸 CSTA 3B-AP-17
- Write a numbered requirements document for a given problem, including at least two functional requirements and one non-functional requirement, each specific and testable. 🇺🇸 AP CSP CRD-2.A / 🇨🇦 ON ICS3U B4为给定问题编写编号需求文档,包括至少两个功能性需求和一个非功能性需求,每个都具体且可测试。🇺🇸 AP CSP CRD-2.A / 🇨🇦 ON ICS3U B4
- Produce two design artifacts for a given problem: a pseudocode/flowchart for an algorithm AND a UML class diagram showing at least two attributes and one method. 🇨🇦 ON ICS3U B2.4 / BC CP11为给定问题产出两种设计制品:算法的伪代码/流程图以及显示至少两个属性和一个方法的 UML 类图。🇨🇦 ON ICS3U B2.4 / BC CP11
- Identify the four coding standard violations in a given code snippet (poor names, magic numbers, useless comments, inconsistent indentation) and rewrite it to standards. 🇨🇦 BC CP11 "inline commenting" / ON ICS3U B2.4识别给定代码片段中的四个编码规范违规(命名不佳、魔法数字、无用注释、缩进不一致),并按规范重写。🇨🇦 BC CP11"内联注释" / ON ICS3U B2.4
- Write a complete 4-column test plan (scenario / input / expected output / pass-fail) with at least three rows covering normal, boundary, and error cases for a grade calculator. 🇨🇦 ON ICS3U B4.4 / AB CSE1110 1.7为成绩计算器编写完整的 4 列测试计划(场景/输入/预期输出/通过失败),至少 3 行,涵盖正常、边界和错误情况。🇨🇦 ON ICS3U B4.4 / AB CSE1110 1.7
- Distinguish between syntax, logic, and runtime errors with one concrete Python example of each. State which type appears in a given buggy code snippet. 🇨🇦 AB CSE1110 3.1 / BC CP11用一个具体的 Python 示例区分语法、逻辑和运行时错误。说明给定有错误代码片段中出现哪种类型。🇨🇦 AB CSE1110 3.1 / BC CP11
- Write a properly documented Python function: docstring with parameters and return value, named constants instead of magic numbers, and at least one inline comment explaining WHY. 🇨🇦 BC CP12 "Standardized source code documentation"编写一个有适当文档的 Python 函数:包含参数和返回值的文档字符串、用命名常量替换魔法数字、至少一个解释为什么的内联注释。🇨🇦 BC CP12"标准化源代码文档"
- Name and distinguish all three maintenance types (corrective, adaptive, perfective) and give a real-world example of each for a school homework-tracker app. 🇺🇸 CSTA 3B-AP-22 / 🇨🇦 ON ICS3U B4.1命名并区分全部三种维护类型(纠正性、适应性、完善性),并为学校作业追踪应用举出每种类型的真实示例。🇺🇸 CSTA 3B-AP-22 / 🇨🇦 ON ICS3U B4.1
- Explain what each of the four Git commands does (
git init,git add,git commit,git push) and use them in a sentence describing a team project workflow. 🇨🇦 ON ICS4U B1.7 / BC CP11解释四个 Git 命令各自的作用(git init、git add、git commit、git push),并在一句话中描述团队项目工作流。🇨🇦 ON ICS4U B1.7 / BC CP11 - Identify which SDLC phase a given scenario belongs to (given 5 scenario cards, correctly place all five). Applicable to any curriculum. 🇨🇦 ON ICS3U B4 / 🇺🇸 CSTA 3B-AP-17识别给定场景属于哪个 SDLC 阶段(给定 5 张场景卡,正确放置所有五张)。适用于任何课程。🇨🇦 ON ICS3U B4 / 🇺🇸 CSTA 3B-AP-17
- Honors — ICS4U B1 / CSTA 3B-AP-20 Explain the pull-request code review workflow (feature branch → PR → review → merge) and state why it prevents untested code from entering the main codebase. 🇨🇦 ON ICS4U B1.7 / 🇺🇸 CSTA 3B-AP-20荣誉 — ICS4U B1 / CSTA 3B-AP-20 解释拉取请求代码审查工作流(功能分支 → PR → 审查 → 合并),并说明为什么它能防止未经测试的代码进入主代码库。🇨🇦 ON ICS4U B1.7 / 🇺🇸 CSTA 3B-AP-20
What This Feeds Into本单元的去向
Software development process skills underpin every subsequent unit in this series. The SDLC framework you learned here is the scaffold for every project you will build: requirements before design, design before code, code before testing, testing before deployment. The design tools (pseudocode, flowcharts, UML) resurface in every future guide. Version control with Git is expected throughout any professional or advanced academic programming course.软件开发过程技能支撑本系列的每个后续单元。你在这里学到的 SDLC 框架是你将构建的每个项目的支架:需求先于设计,设计先于编码,编码先于测试,测试先于部署。设计工具(伪代码、流程图、UML)在每个未来指南中重现。Git 版本控制在任何专业或高级学术编程课程中都是预期技能。
Within High School Computer Science.在 HS Computer Science 内部。
Every subsequent HS CS unit applies the SDLC: the Control Flow unit produces flowcharts and pseudocode (Design phase) before writing Python; the Functions and Modular Design unit formalises the decomposition discipline into callable sub-programs; the Object-Oriented Programming unit uses UML class diagrams as its primary design tool. The testing and version-control habits from this guide carry through all of them.每个后续 HS CS 单元都应用 SDLC:控制流单元在编写 Python 之前产出流程图和伪代码(设计阶段);函数与模块化设计单元将分解纪律正式化为可调用子程序;面向对象编程单元使用 UML 类图作为主要设计工具。本指南中的测试和版本控制习惯贯穿所有这些单元。
AP feeder links (existing in this repo).AP 衔接链接(本仓库中已有)。
AP CSP Big Idea 1 (Creative Development, 10–13% of the exam) is a direct assessment of the SDLC skills in this guide — CRD-2.A through CRD-2.J map to requirements, design, implementation, testing, and debugging. The AP CSP Create Performance Task requires students to document their development process, which is exactly the documentation skills in §6. AP CSA (Java-specific) expects you to bring version control discipline, UML reading ability, and test-plan writing from a prior course — this guide delivers those prerequisites.AP CSP 大概念 1(创意开发,占考试 10–13%)直接评估本指南中的 SDLC 技能——CRD-2.A 至 CRD-2.J 对应需求、设计、实现、测试和调试。AP CSP 创作绩效任务要求学生记录其开发过程,这正是 §6 中的文档技能。AP CSA(Java 专项)期望你从先修课程中带来版本控制纪律、UML 阅读能力和测试计划编写能力——本指南提供这些前提条件。