High School Computer Science

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,但概念适用于任何语言。

7 sections7 节内容 US CSTA · AP CSP · ON · BC · ABUS CSTA · AP CSP · ON · BC · AB SDLC phases + Git intro + worked examplesSDLC 各阶段 + Git 入门 + 例题

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.找到所在行后,用下面两张卡片决定推进速度。

!
If you are cramming the night before如果你在临阵磨枪

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 深入内容。

*
If you are going for the top mark如果你目标顶分

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 命令。

Version control note.版本控制说明。 Section 7 (Collaboration and Version Control) introduces Git at a conceptual level: the four commands (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 initgit addgit commitgit push)和分支合并工作流。Honors 标记深入框,涵盖分支策略和拉取请求代码审查。该框对应安大略 ICS4U B1.7(版本控制)和 CSTA 3B-AP-20("在团队软件项目中使用版本控制系统……")。对于 ICS3U / CSE1110 / AP CSP 基础学生,理解版本控制是什么及其重要性是被评估的层次;考试中不需要演示 Git 命令。

The Software Development Life Cycle软件开发生命周期

The seven SDLC phases — memorise these in order.七个 SDLC 阶段 — 按顺序背熟。
  • 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.— 修复发布后出现的错误,添加新功能,并随着需求变化调整软件。
Waterfall vs Agile: the waterfall model runs the seven phases in strict sequence (plan everything before coding). Agile iterates in short sprints, revisiting requirements → design → code → test in quick cycles. Ontario ICS3U B4.1 names the phases explicitly; CSTA 3B-AP-17 says "processes could include agile, spiral, or waterfall."瀑布模型与敏捷:瀑布模型按严格顺序执行七个阶段(在编码前规划好一切)。敏捷以短冲刺迭代,在快速循环中反复经历需求 → 设计 → 编码 → 测试。安大略 ICS3U B4.1 明确命名各阶段;CSTA 3B-AP-17 说"过程可包括敏捷、螺旋或瀑布"。
WE
Worked Example 1 · Mapping a homework tracker through the SDLC例题 1 · 作业追踪应用的 SDLC 阶段分析

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.用户报告截止日期相同的任务显示顺序不正确——修复排序比较器并更新版本号。

A developer fixes a bug that appeared six months after the software was released to users. Which SDLC phase does this fix belong to?一名开发人员修复了软件发布给用户六个月后出现的错误。这个修复属于 SDLC 的哪个阶段?
§1 · Q1
Testing测试
Implementation实现
Maintenance维护
Analysis分析
Maintenance is the phase after deployment that handles bug fixes, security patches, and feature additions in live software. Ontario ICS3U B4.1 names maintenance as the final SDLC phase.维护是部署后处理实时软件中的错误修复、安全补丁和功能添加的阶段。安大略 ICS3U B4.1 将维护列为最后一个 SDLC 阶段。
Testing happens before deployment; implementation is writing the original code; analysis studies requirements. Post-release bug fixing is maintenance.测试在部署之前进行;实现是编写原始代码;分析研究需求。发布后的错误修复是维护。
Which SDLC phase produces design artifacts such as flowcharts, pseudocode, and UML diagrams?SDLC 的哪个阶段产出流程图、伪代码和 UML 图等设计制品?
§1 · Q2
Design设计
Implementation实现
Requirements需求
Testing测试
The design phase converts requirements and analysis into concrete blueprints: flowcharts, pseudocode, UML class and sequence diagrams, data-structure sketches, and UI wireframes. Ontario ICS3U B2.4 lists structure charts, flowcharts, UML, pseudocode as the accepted design tools.设计阶段将需求和分析转化为具体的蓝图:流程图、伪代码、UML 类图和序列图、数据结构草图和 UI 线框图。安大略 ICS3U B2.4 将结构图、流程图、UML、伪代码列为公认的设计工具。
Implementation writes the actual code; requirements gathers user needs; testing verifies correctness. Design is where you plan how the code will be structured before writing it.实现编写实际代码;需求收集用户需求;测试验证正确性。设计是在编写代码之前规划代码结构的阶段。
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需求与规划

Two types of requirements — memorise the distinction.两类需求 — 背熟这个区别。
  • 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 秒内完成。"涵盖性能、安全性、无障碍性和可维护性。
Requirements document format: each requirement should be numbered, specific, and testable. "The app should be fast" is bad — not testable. "The app must load the task list in under 500 ms on a 4G connection" is good — measurable. Ontario ICS3U B4.1 and AP CSP CRD-2.A require capturing requirements before design.需求文档格式:每个需求应编号、具体且可测试。"应用程序应该快"是错误的——无法测试。"应用程序必须在 4G 连接下 500 毫秒内加载任务列表"是正确的——可量化。安大略 ICS3U B4.1 和 AP CSP CRD-2.A 要求在设计之前捕获需求。
WE
Worked Example 2 · Writing requirements for a grade calculator例题 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")且可测试。

Which of the following is a well-written functional requirement?以下哪项是写得好的功能性需求?
§2 · Q1
The app should be user-friendly.应用程序应该用户友好。
The user shall be able to search for a task by name and the result shall appear within 1 second.用户应能按名称搜索任务,结果应在 1 秒内显示。
The code should be clean and well-commented.代码应该干净且注释良好。
The database should be fast.数据库应该快速。
A good requirement is specific, numbered, and testable. Option B states exactly what the user can do (search by name) and a measurable criterion (1 second). The other options are vague and cannot be tested with a pass/fail result.好的需求具体、有编号且可测试。选项 B 准确说明用户可以做什么(按名称搜索)以及可量化的标准(1 秒)。其他选项含糊,无法用通过/失败结果进行测试。
"User-friendly," "clean code," and "fast database" are unmeasurable. A requirement must be specific enough to write a test case for it — you need a concrete action and a measurable outcome."用户友好"、"干净代码"和"快速数据库"无法量化。需求必须具体到可以为其编写测试用例——你需要一个具体的操作和可量化的结果。
A requirement states: "The login must complete in under 2 seconds on a standard 4G connection." What type of requirement is this?一个需求规定:"登录必须在标准 4G 连接下 2 秒内完成。"这是什么类型的需求?
§2 · Q2
Functional requirement功能性需求
User story用户故事
Use case用例
Non-functional requirement非功能性需求
Non-functional requirements describe performance, security, or quality constraints — how the system must behave, not what it must do. Speed (2 seconds) is a performance constraint, which is a non-functional requirement.非功能性需求描述性能、安全性或质量约束——系统必须如何行为,而非必须做什么。速度(2 秒)是性能约束,属于非功能性需求。
Functional requirements describe what the system does (log in). Non-functional requirements describe how it performs (under 2 seconds). Speed is a performance metric — non-functional.功能性需求描述系统做什么(登录)。非功能性需求描述如何执行(2 秒内)。速度是性能指标——属于非功能性。
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 入门)

Three design tools — when to use each.三种设计工具 — 各自的使用场景。
  • 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.— 用结构化英语描述单个算法的逻辑。最适合在编码前捕获循环/判断逻辑。使用关键字:INPUTOUTPUTIF/ELSEWHILEFORSET 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"列为公认的设计工具。
The rule: always produce at least one design artifact before writing code. AP CSP CRD-2.B states: "Describe the purpose of a code segment or program by writing documentation." Design artifacts are that documentation.规则:在编写代码之前始终产出至少一个设计制品。AP CSP CRD-2.B 指出:"通过编写文档描述代码段或程序的目的。"设计制品就是那份文档。
WE
Worked Example 3 · Design artifacts for a login system例题 3 · 登录系统的设计制品

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 实现由此而来。

Which design tool is most appropriate for showing the logic of a single algorithm with branches and loops before writing code?在编写代码之前,哪种设计工具最适合显示包含分支和循环的单个算法的逻辑?
§3 · Q1
UML class diagramUML 类图
Requirements document需求文档
Pseudocode or flowchart伪代码或流程图
Test plan测试计划
Pseudocode and flowcharts both represent algorithm control flow (sequences, decisions, loops). UML class diagrams show object structure; requirements documents capture what the system must do; test plans verify correctness after implementation.伪代码和流程图都表示算法控制流(顺序、判断、循环)。UML 类图显示对象结构;需求文档捕获系统必须做什么;测试计划在实现后验证正确性。
For algorithm logic with branches/loops: pseudocode (structured English) or flowchart (visual). UML class diagrams are for object structure, not algorithm flow.对于含分支/循环的算法逻辑:伪代码(结构化英语)或流程图(可视化)。UML 类图用于对象结构,而非算法流程。
In a UML class diagram, what does the middle section of the box contain?在 UML 类图中,盒子的中间部分包含什么?
§3 · Q2
The class name类名
The attributes (data fields)属性(数据字段)
The methods (operations)方法(操作)
The test cases测试用例
A UML class box has three sections: top = class name; middle = attributes (data the object stores); bottom = methods (operations the object can perform). Remembering this structure helps you read and draw UML at the design phase.UML 类盒子有三节:顶部 = 类名;中部 = 属性(对象存储的数据);底部 = 方法(对象可执行的操作)。记住这个结构有助于在设计阶段读取和绘制 UML。
UML three-section box: top = name, middle = attributes, bottom = methods. Test cases are part of the test plan, not the class diagram.UML 三节盒子:顶部 = 名称,中部 = 属性,底部 = 方法。测试用例是测试计划的一部分,而非类图。

Implementation and Coding Standards实现与编码规范

Four coding standards every professional applies — memorise these.每位专业人员都要遵守的四条编码规范 — 背熟这些。
  • Meaningful names有意义的命名 — variable and function names should say what they store/do. student_count is good; x is 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-indexed is useful; # add 1 is 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 >= 90 scattered everywhere, use A_THRESHOLD = 90 once 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 要求使用"行业标准"工具。
WE
Worked Example 4 · Refactoring bad code to meet coding standards例题 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: # hot just repeats what the print says. Inconsistent indentation (2 spaces, not 4).命名不佳:xy。魔法数字: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 个空格缩进。逻辑完全相同——只有可读性发生了变化。

Which of the following is an example of a "magic number" that should be replaced with a named constant?以下哪项是应该用命名常量替换的"魔法数字"的例子?
§4 · Q1
student_count = 0
MAX_STUDENTS = 30
for i in range(len(scores)):
if score >= 90: # A grade threshold, hard-coded
A magic number is a hard-coded literal whose meaning is not obvious from context. 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()。
Magic numbers are unexplained hard-coded literals. 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 风格)替换它是修复方法。
Which comment is more useful and follows coding standards?哪条注释更有用并符合编码规范?
§4 · Q2
# add 1 to count
# compensate for 1-based indexing in user input
# this is a loop
# variable
A good comment explains the why — the reason behind a non-obvious decision. "Compensate for 1-based indexing" explains why the code subtracts 1, which is not obvious from the code itself. The other options just describe what the code does (which the code already shows).好的注释解释为什么——非显而易见决定背后的原因。"补偿基于 1 的索引"解释了代码为什么减去 1,这从代码本身并不明显。其他选项只是描述代码做什么(代码本身已经显示了)。
Useful comments explain WHY, not WHAT. "Add 1 to count" is useless — the code already shows that. "Compensate for 1-based indexing" explains the reasoning.有用的注释解释为什么,而非是什么。"将 count 加 1"是无用的——代码已经显示了这一点。"补偿基于 1 的索引"解释了推理过程。
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 plan structure — four columns, Ontario ICS3U B4.4 names these verbatim.测试计划结构 — 四列,安大略 ICS3U B4.4 逐字命名这些列。
  • 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.— 程序实际产生的内容,以及是否与预期输出匹配。
Three error types (BC CP11 names these): (1) Syntax: code fails to parse — a typo or missing colon. (2) Logic: code runs but produces the wrong answer — the algorithm is flawed. (3) Runtime (semantic): code crashes during execution — division by zero, index out of bounds. Always test normal cases, boundary cases, and error/exception cases — AB CSE1110 outcome 1.7: "test the algorithm for failure as well as success."三种错误类型(BC CP11 命名这些):(1) 语法:代码解析失败——错别字或缺少冒号。(2) 逻辑:代码运行但产生错误答案——算法有缺陷。(3) 运行时(语义):代码在执行过程中崩溃——除以零、索引越界。始终测试正常情况边界情况错误/异常情况——AB CSE1110 结果 1.7:"用适当数据测试算法的成功与失败情况。"
WE
Worked Example 5 · Test plan for a grade calculator例题 5 · 成绩计算器的测试计划

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)处的边界情况至关重要——它们测试是否正确使用 >= 而非 >。这里的差一错误是逻辑错误。

A grade calculator outputs "A" when the score is 89. The expected output is "B". What type of error is this?一个成绩计算器在分数为 89 时输出"A"。预期输出是"B"。这是什么类型的错误?
§5 · Q1
Logic error (off-by-one in the boundary condition)逻辑错误(边界条件中的差一错误)
Syntax error语法错误
Runtime error运行时错误
No error — the output is correct无错误——输出是正确的
The program runs without crashing (not syntax or runtime) but produces the wrong answer — that is a logic error. The likely cause is 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。这是差一边界错误。
Syntax errors prevent parsing; runtime errors crash the program. Wrong answer without crash = logic error. Boundary conditions (> vs >=) are a classic source of logic errors.语法错误阻止解析;运行时错误使程序崩溃。无崩溃的错误答案 = 逻辑错误。边界条件(> 与 >=)是逻辑错误的经典来源。
According to Ontario ICS3U B4.4, a test plan must include which four elements?根据安大略 ICS3U B4.4,测试计划必须包括哪四个要素?
§5 · Q2
Code, comments, variable names, output代码、注释、变量名、输出
Algorithm, pseudocode, flowchart, UML算法、伪代码、流程图、UML
Test scenario, input data, expected output, actual outcome + pass/fail测试场景、输入数据、预期输出、实际结果 + 通过/失败
Requirements, design, implementation, maintenance需求、设计、实现、维护
Ontario ICS3U B4.4 (verbatim): "use a test plan to test programs (i.e., identify test scenarios, identify suitable input data, calculate expected outcomes, record actual outcomes, and conclude 'pass' or 'fail')." These four elements make a test plan verifiable and repeatable.安大略 ICS3U B4.4(原文):"使用测试计划测试程序(即确定测试场景、确定合适的输入数据、计算预期结果、记录实际结果,并得出'通过'或'失败'的结论)。"这四个要素使测试计划可验证且可重复。
A test plan is not design documentation (algorithms/UML) nor SDLC phases. It is a table: scenario | input | expected | actual | pass/fail — as stated in Ontario ICS3U B4.4.测试计划不是设计文档(算法/UML),也不是 SDLC 阶段。它是一个表格:场景 | 输入 | 预期 | 实际 | 通过/失败——如安大略 ICS3U B4.4 所述。
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文档与维护

Three documentation types — each has a different audience.三种文档类型 — 各有不同的受众。
  • 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、用户指南和错误消息说明。用简明语言编写,无代码。
Maintenance is the longest SDLC phase — most software is maintained for years after release. Maintenance activities: corrective (fix bugs), adaptive (update for new OS/hardware), perfective (add features or improve performance). CSTA 3B-AP-22 (verbatim): "Modify an existing program to add additional functionality and discuss intended and unintended implications."维护是最长的 SDLC 阶段——大多数软件在发布后维护多年。维护活动:纠正性(修复错误)、适应性(为新操作系统/硬件更新)、完善性(添加功能或提高性能)。CSTA 3B-AP-22(原文):"修改现有程序以添加附加功能,并讨论预期和非预期的影响。"
WE
Worked Example 6 · Documenting a grade calculator function例题 6 · 为成绩计算器函数编写文档

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 文档。内联注释解释为什么。模块头是面向任何阅读文件的人的用户文档。

A school's homework-tracker app runs on an old OS version. The developers update the app to work on the new OS without adding features. What type of maintenance is this?一所学校的作业追踪应用在旧版操作系统上运行。开发人员更新应用以在新操作系统上运行,未添加新功能。这是什么类型的维护?
§6 · Q1
Corrective maintenance纠正性维护
Adaptive maintenance适应性维护
Perfective maintenance完善性维护
Documentation maintenance文档维护
Adaptive maintenance updates software to work in a changed environment (new OS, new hardware, new platform) without changing functionality. Corrective fixes bugs; perfective improves features or performance. No new feature = not perfective; no bug = not corrective; environment change = adaptive.适应性维护将软件更新为在变化的环境(新操作系统、新硬件、新平台)中工作,而不改变功能。纠正性修复错误;完善性改进功能或性能。无新功能 = 非完善性;无错误 = 非纠正性;环境变化 = 适应性。
Three maintenance types: corrective (fix bugs), adaptive (update for new environment), perfective (improve/add features). Updating for a new OS without feature changes is adaptive.三种维护类型:纠正性(修复错误)、适应性(为新环境更新)、完善性(改进/添加功能)。在无功能变化的情况下为新操作系统更新是适应性维护。
Which documentation type is intended for end users who need to install and use the software?哪种文档类型面向需要安装和使用软件的最终用户?
§6 · Q2
Inline comments内联注释
API referenceAPI 参考
Architecture diagram架构图
User guide / README用户指南 / README
User documentation (user guide, README) is written for end users in plain language. It covers installation, basic usage, and common errors. Inline comments, API references, and architecture diagrams are developer-facing technical documentation, not user-facing.用户文档(用户指南、README)用简明语言为最终用户编写。它涵盖安装、基本使用和常见错误。内联注释、API 参考和架构图是面向开发人员的技术文档,而非面向用户。
End users don't read code comments or API references. User documentation = plain-language guides written for non-developers. The README is the classic example.最终用户不阅读代码注释或 API 参考。用户文档 = 为非开发人员编写的简明语言指南。README 是经典示例。

Collaboration and Version Control (Git Intro)协作与版本控制(Git 入门)

Four core Git commands — know what each does.四个核心 Git 命令 — 了解每个命令的作用。
  • git init — initialise a new Git repository in the current folder. Creates a hidden .git directory 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)。使团队成员能够访问你的工作。
Why version control matters: it lets you revert to a previous working version when a change breaks things; it enables multiple developers to work on the same codebase without overwriting each other's work (branches); and it provides a complete audit trail of who changed what and why (commit messages). Ontario ICS4U B1.7 (verbatim): "use shared resources to manage source code effectively and securely … proper version control." BC CP11: "collaboration tools for programming." BC CP12: "Collaboration tools for programming; Advanced pair programming."版本控制的重要性:当更改破坏程序时,它让你能够恢复到之前的可用版本;它使多个开发人员能够在同一代码库上工作而不互相覆盖(分支);它提供完整的审计跟踪,记录谁改变了什么以及为什么(提交消息)。安大略 ICS4U B1.7(原文):"使用共享资源有效、安全地管理源代码……正确的版本控制。" BC CP11:"编程协作工具。" BC CP12:"编程协作工具;高级结对编程。"
WE
Worked Example 7 · A typical Git workflow for a school project例题 7 · 学校项目的典型 Git 工作流

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"将代码更改与测试计划行关联起来,形成需求 → 设计 → 实现 → 测试 → 修复的完整闭环。

What does git commit -m "Add login function" do?git commit -m "Add login function" 做什么?
§7 · Q1
Uploads all local files to GitHub将所有本地文件上传到 GitHub
Marks a file as ready to be saved将文件标记为准备保存
Saves a permanent snapshot of all staged files with the message "Add login function"用消息"Add login function"保存所有暂存文件的永久快照
Creates a new Git repository创建一个新的 Git 仓库
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
Git workflow: init → add (stage) → commit (snapshot) → push (upload). commit saves locally; push uploads to remote.Git 工作流:init → add(暂存)→ commit(快照)→ push(上传)。commit 本地保存;push 上传到远程。
Two students edit the same Python file simultaneously on separate computers. Which Git concept prevents their changes from overwriting each other?两名学生在不同的计算机上同时编辑同一个 Python 文件。哪个 Git 概念防止他们的更改互相覆盖?
§7 · Q2
Branches (each student works on a separate branch, then merges)分支(每个学生在单独的分支上工作,然后合并)
Commit messages提交消息
The git push commandgit push 命令
The README fileREADME 文件
Branches allow parallel development: each developer creates their own branch, makes changes independently, then merges back into the main branch. Git identifies conflicts (two people editing the same lines) and requires manual resolution before the merge completes. This is the core collaboration mechanism in Git.分支允许并行开发:每个开发人员创建自己的分支,独立进行更改,然后合并回主分支。Git 识别冲突(两人编辑同一行),并在合并完成前需要手动解决。这是 Git 的核心协作机制。
Commit messages record what changed; git push uploads commits; README is documentation. Branches are the Git feature that enables parallel development and prevents accidental overwrites through structured merging.提交消息记录更改内容;git push 上传提交;README 是文档。分支是 Git 功能,通过结构化合并实现并行开发并防止意外覆盖。
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考试策略与常见陷阱

SDLC questions (§1)SDLC 问题(§1)
  • 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 命名了两者;各知道一个优点和一个缺点。
Requirements and design questions (§2-§3)需求和设计问题(§2-§3)
  • 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。
Testing and debugging questions (§5)测试和调试问题(§5)
  • 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 都要求对失败和成功情况都进行测试。只有正常情况的测试计划会失分。
Documentation and version control (§6-§7)文档和版本控制(§6-§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 initgit addgit commitgit 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 initgit addgit commitgit push。了解每个命令的作用。ICS4U B1.7 可能要求你描述版本控制;了解这四个命令为你提供具体、可引用的细节。

Flashcards闪卡

0 / 14 flipped0 / 14 已翻
What is the SDLC?什么是软件开发生命周期(SDLC)?
Software Development Life Cycle — the structured process for building software: Requirements → Analysis → Design → Implementation → Testing → Documentation/Deployment → Maintenance.软件开发生命周期——构建软件的结构化过程:需求 → 分析 → 设计 → 实现 → 测试 → 文档/部署 → 维护。
SDLC phase: MaintenanceSDLC 阶段:维护
Post-deployment phase: fix bugs (corrective), update for new environment (adaptive), or add/improve features (perfective). CSTA 3B-AP-22.部署后阶段:修复错误(纠正性)、为新环境更新(适应性)或添加/改进功能(完善性)。CSTA 3B-AP-22。
Functional vs non-functional requirement功能性 vs 非功能性需求
Functional = what the system does ("user can log in"). Non-functional = how it performs ("login completes in <2 seconds"). Both must be specific and testable.功能性 = 系统做什么("用户可以登录")。非功能性 = 如何执行("登录在 2 秒内完成")。两者都必须具体且可测试。
Three design tools三种设计工具
Pseudocode — algorithm logic. Flowchart — visual control flow (oval/rect/diamond/parallelogram). UML class diagram — object structure (name/attributes/methods). ON ICS3U B2.4.伪代码——算法逻辑。流程图——可视化控制流(椭圆/矩形/菱形/平行四边形)。UML 类图——对象结构(名称/属性/方法)。ON ICS3U B2.4。
UML class box structureUML 类盒子结构
Three sections: top = class name; middle = attributes (- private, + public); bottom = methods (+ public). ON ICS3U B2.4 accepts UML as a design tool.三节:顶部 = 类名;中部 = 属性(- 私有,+ 公有);底部 = 方法(+ 公有)。ON ICS3U B2.4 接受 UML 作为设计工具。
Four coding standards四条编码规范
1. Meaningful names. 2. Inline comments explain WHY. 3. No magic numbers — use named constants. 4. Consistent indentation (4 spaces Python). BC CP11: "inline commenting to document source code."1. 有意义的命名。2. 内联注释解释为什么。3. 无魔法数字——使用命名常量。4. 一致缩进(Python 4 个空格)。BC CP11:"内联注释记录源代码。"
Test plan: four columns测试计划:四列
Scenario | Input data | Expected output | Actual output + Pass/Fail. ON ICS3U B4.4 verbatim: "identify test scenarios, identify suitable input data, calculate expected outcomes, record actual outcomes, conclude pass or fail."场景 | 输入数据 | 预期输出 | 实际输出 + 通过/失败。ON ICS3U B4.4 原文:"确定测试场景、确定合适的输入数据、计算预期结果、记录实际结果,得出通过或失败结论。"
Three test case types三种测试用例类型
Normal cases — typical valid input. Boundary cases — exact edges of conditions (e.g., score=90). Error/exception cases — invalid input (e.g., score=150). AB CSE1110 1.7: test for failure as well as success.正常情况——典型有效输入。边界情况——条件精确边缘(如 score=90)。错误/异常情况——无效输入(如 score=150)。AB CSE1110 1.7:对失败和成功情况都进行测试。
Three error types三种错误类型
Syntax: code fails to parse (typo, missing colon). Logic: wrong answer, no crash. Runtime/semantic: crash during execution (division by zero, index out of range). BC CP11: "logical or semantic errors."语法:代码解析失败(错别字、缺少冒号)。逻辑:答案错误,无崩溃。运行时/语义:执行期间崩溃(除以零、索引越界)。BC CP11:"逻辑或语义错误。"
Three documentation types三种文档类型
Inline comments → developers (explain WHY). Technical docs/API reference → developer-maintainers. User guide/README → end users (plain language). BC CP12: "Standardized source code documentation."内联注释 → 开发人员(解释为什么)。技术文档/API 参考 → 开发维护人员。用户指南/README → 最终用户(简明语言)。BC CP12:"标准化源代码文档。"
Three maintenance types三种维护类型
Corrective — fix bugs. Adaptive — update for new environment (new OS, hardware). Perfective — add/improve features or performance. CSTA 3B-AP-22: "Modify an existing program to add additional functionality."纠正性——修复错误。适应性——为新环境更新(新操作系统、硬件)。完善性——添加/改进功能或性能。CSTA 3B-AP-22:"修改现有程序以添加附加功能。"
Four core Git commands (in order)四个核心 Git 命令(按顺序)
git init (create repo) → git add (stage files) → git commit -m "msg" (save snapshot) → git push (upload to remote). ON ICS4U B1.7: "use shared resources to manage source code … proper version control."git init(创建仓库)→ git add(暂存文件)→ git commit -m "消息"(保存快照)→ git push(上传到远程)。ON ICS4U B1.7:"使用共享资源管理源代码……正确的版本控制。"
What is a branch in Git?Git 中的分支是什么?
A parallel line of development that does not affect the main codebase. Developers work on a feature branch, then merge it into main via a pull request after code review. CSTA 3B-AP-20: version control in group projects.不影响主代码库的并行开发线。开发人员在功能分支上工作,然后通过代码审查后的拉取请求将其合并到主分支。CSTA 3B-AP-20:团队项目中的版本控制。
Waterfall vs Agile瀑布 vs 敏捷
Waterfall: phases in strict order, all planned upfront — predictable but inflexible. Agile: iterative 2-week sprints, requirements can change — flexible but requires constant communication. CSTA 3B-AP-17.瀑布:严格按阶段顺序,全部提前规划——可预测但不灵活。敏捷:迭代的 2 周冲刺,需求可以变化——灵活但需要持续沟通。CSTA 3B-AP-17。

Practice Quiz综合测验

A developer is writing a program to manage student records. Before opening a code editor, they produce a flowchart and a list of numbered requirements. Which two SDLC phases have they just completed?一名开发人员正在编写一个管理学生记录的程序。在打开代码编辑器之前,他们制作了一个流程图和一个编号需求列表。他们刚刚完成了哪两个 SDLC 阶段?
Q1
Implementation and Testing实现和测试
Testing and Maintenance测试和维护
Requirements and Design需求和设计
Analysis and Deployment分析和部署
A numbered requirements list comes from the Requirements phase; a flowchart is a Design artifact. The SDLC sequence is Requirements → Analysis → Design → Implementation → Testing → Deployment → Maintenance.编号需求列表来自需求阶段;流程图是设计制品。SDLC 顺序为需求 → 分析 → 设计 → 实现 → 测试 → 部署 → 维护。
Flowchart = design artifact. Numbered requirements = requirements phase. Together they represent Requirements and Design — two early SDLC phases before implementation.流程图 = 设计制品。编号需求 = 需求阶段。合在一起代表需求和设计——实现之前的两个早期 SDLC 阶段。
A requirement states: "The login page must work on mobile browsers." What type of requirement is this?一个需求规定:"登录页面必须在手机浏览器上运行。"这是什么类型的需求?
Q2
Non-functional requirement非功能性需求
Functional requirement功能性需求
Test plan测试计划
Maintenance requirement维护需求
This requirement specifies something the system must DO (work on mobile browsers) — that is a functional requirement. Non-functional requirements describe HOW the system performs (speed, security, memory usage).这个需求规定了系统必须做的事情(在手机浏览器上运行)——这是功能性需求。非功能性需求描述系统如何执行(速度、安全性、内存使用)。
Functional = what the system does. Non-functional = how it performs. "Works on mobile" is what the system must do — functional. Speed/security constraints would be non-functional.功能性 = 系统做什么。非功能性 = 如何执行。"在手机上运行"是系统必须做的——功能性。速度/安全性约束是非功能性的。
A software team discovers that a critical feature was not included in the requirements document. The team now has to redesign and re-implement significant portions of the program. Which poor practice caused this?一个软件团队发现需求文档中遗漏了一个关键功能。团队现在必须重新设计和重新实现程序的大部分内容。这是哪种不良实践导致的?
Q3
Skipping or rushing the requirements phase跳过或仓促完成需求阶段
Using too many inline comments使用过多内联注释
Choosing Git as the version control system选择 Git 作为版本控制系统
Writing too many test cases编写过多测试用例
Incomplete requirements lead to expensive rework later. The cost of fixing a requirement error discovered during implementation is far higher than discovering it during the requirements phase. This is why Ontario ICS3U B4.1 requires capturing all SDLC phases, and AP CSP CRD-2.A requires understanding program purpose before development begins.不完整的需求会导致后期昂贵的返工。在实现阶段发现需求错误的修复成本远高于在需求阶段发现它。这就是为什么安大略 ICS3U B4.1 要求捕获所有 SDLC 阶段,而 AP CSP CRD-2.A 要求在开发开始之前理解程序目的。
The problem is incomplete requirements — missing a feature before design/implementation means expensive redesign. Good requirements documents prevent this. Too many comments or test cases are not harmful; skipping requirements is.问题在于不完整的需求——在设计/实现之前遗漏功能意味着昂贵的重新设计。好的需求文档可以防止这种情况。过多注释或测试用例无害;跳过需求才有害。
Which variable name best follows coding standards for a variable that stores the total number of students enrolled?以下哪个变量名最符合存储已注册学生总数变量的编码规范?
Q4
x
n
students
total_enrolled_students
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"作为此目的的变量名毫无意义。
Meaningful names are a core coding standard. The name should reveal intent without a comment. "total_enrolled_students" is self-documenting; "x" and "n" require a comment to understand.有意义的命名是核心编码规范。名称应该在不需要注释的情况下揭示意图。"total_enrolled_students"是自文档化的;"x"和"n"需要注释才能理解。
A student writes a test plan for a login function. They include one test: username="admin", password="pass123" → expected output "Login successful." What is missing from this test plan?一名学生为登录功能编写测试计划。他们包含一个测试:username="admin",password="pass123"→ 预期输出"登录成功"。这个测试计划缺少什么?
Q5
A flowchart流程图
A UML class diagramUML 类图
Boundary and error test cases (e.g., wrong password, empty username)边界和错误测试用例(如密码错误、用户名为空)
Nothing — one test case is sufficient没有——一个测试用例就足够了
A complete test plan requires normal cases, boundary cases, and error/exception cases. One normal case is only the minimum. AB CSE1110 outcome 1.7: "test the algorithm for failure as well as success." BC CP11: "use of test cases to detect logical or semantic errors." Test plans should also test wrong password, empty fields, SQL-injection-like inputs, etc.完整的测试计划需要正常情况、边界情况和错误/异常情况。一个正常情况只是最低要求。AB CSE1110 结果 1.7:"用适当数据测试算法的成功与失败情况。" BC CP11:"使用测试用例检测逻辑或语义错误。"测试计划还应测试错误密码、空字段、类 SQL 注入输入等。
One normal test case is insufficient. A proper test plan covers: normal (correct creds), boundary (exact length limits), error (wrong password, empty username, special characters). Flowcharts and UML are design tools, not part of a test plan.一个正常测试用例不够。适当的测试计划涵盖:正常(正确凭据)、边界(精确长度限制)、错误(错误密码、空用户名、特殊字符)。流程图和 UML 是设计工具,而非测试计划的一部分。
Which command uploads your local Git commits to a remote repository like GitHub?哪个命令将本地 Git 提交上传到 GitHub 等远程仓库?
Q6
git commit
git push
git add
git init
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。
Git workflow: init (create repo) → add (stage) → commit (local snapshot) → push (upload to remote). Only push sends data to GitHub.Git 工作流程:init(创建仓库)→ add(暂存)→ commit(本地快照)→ push(上传到远程)。只有 push 将数据发送到 GitHub。
Which CSTA standard says "Plan and develop programs for broad audiences using a software life cycle process"? 🇺🇸 CSTA哪个 CSTA 标准说"使用软件生命周期流程为广大受众规划和开发程序"?🇺🇸 CSTA
Q7
3B-AP-17
3B-AP-16
3B-AP-22
3B-AP-20
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 other standards: 3B-AP-16 = code reuse/libraries; 3B-AP-22 = modify existing programs; 3B-AP-20 = version control in group projects.CSTA 3B-AP-17(原文):"使用软件生命周期流程为广大受众规划和开发程序。流程可包括敏捷、螺旋或瀑布。"其他标准:3B-AP-16 = 代码复用/库;3B-AP-22 = 修改现有程序;3B-AP-20 = 团队项目中的版本控制。
3B-AP-17 = software life cycle process. 3B-AP-16 = code reuse using libraries/APIs. 3B-AP-22 = modify existing program. 3B-AP-20 = version control in group projects.3B-AP-17 = 软件生命周期流程。3B-AP-16 = 使用库/API 的代码复用。3B-AP-22 = 修改现有程序。3B-AP-20 = 团队项目中的版本控制。

Readiness Checklist准备就绪清单

Tick each item when you can do it cold, without notes, on a first attempt.能在无笔记、首次尝试下完成,再勾选每一项。

0 / 11 mastered已掌握 0 / 11

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 阅读能力和测试计划编写能力——本指南提供这些前提条件。