📚 Year 8 CCEA Computer Science: Case Study in Action | Year 8 CCEA 计算机:案例分析实战演练
Welcome to this practical case study where we will step into the shoes of a systems analyst and junior programmer. You will work through a real-world scenario, applying the computational thinking skills you have learned in Year 8 CCEA Computer Science. By the end, you will have designed a simple digital solution, documented your thinking, and reflected on how computing can solve everyday problems.
欢迎来到这个实战案例分析,我们将扮演系统分析师和初级程序员的角色。你将运用在 Year 8 CCEA 计算机课程中学到的计算思维技能,完成一个真实场景的任务。最终,你会设计出一个简单的数字化解决方案,记录你的思维过程,并反思计算技术如何解决日常问题。
1. Setting the Scene – The Book Swap Challenge | 场景设定——图书交换挑战
Our school library has noticed that many students have books at home that they no longer read, while others are looking for new titles. The librarian wants a computer-based system to help students swap books with each other. The goal is to allow students to list the books they are willing to give away and to search for books they want. If a match is found, the system should suggest a potential swap.
学校图书馆发现,很多学生家里都有不再阅读的书籍,而另一些学生正在寻找新书阅读。图书馆老师希望有一个计算机系统来帮助学生互相交换图书。目标是让学生列出自己愿意送出的书籍,并搜索自己想要的书。如果找到匹配,系统应推荐一次可能的交换。
Working as a team of two, you and a partner will analyse this problem, break it down into manageable parts, design an algorithm, and test your logic. This mirrors how professional software developers approach a project from scratch.
你和搭档将组成两人小组来分析这个问题,把它拆解成可管理的部分,设计算法并测试逻辑。这反映了专业软件开发人员从零开始应对项目的方式。
2. Identifying Requirements – What Does the System Need to Do? | 确定需求——系统需要做什么?
Before writing a single line of code, we must gather clear requirements. After interviewing the librarian and a few students, we identify three core functions: (1) allow a student to register a book they wish to give away, (2) allow a student to search for a book they want, and (3) notify both students when a match occurs. A fourth desirable feature is the ability to display all available books.
在写任何代码之前,我们必须收集明确的需求。通过采访图书馆老师和几位学生,我们确定了三个核心功能:(1)让学生登记自己愿意送出的书,(2)让学生搜索想要的书,(3)当出现匹配时通知两位学生。第四个理想功能是能够显示所有可获得的书籍。
These requirements help us set boundaries for the project. We note that the system will store data temporarily (only while the program is running), and it does not need to include real names — student ID numbers can be used instead to protect privacy. This early discussion also highlights the importance of data protection, a key concern in computing today.
这些需求帮助我们为项目设定边界。我们注意到,系统将临时存储数据(仅在程序运行时),并且不需要包含真实姓名——可以用学生学号来代替以保护隐私。这个早期讨论也凸显了数据保护的重要性,这是当今计算领域的一个关键问题。
3. Decomposition – Breaking the Problem into Smaller Parts | 分解——把问题拆分成小部分
Computational thinking starts with decomposition. The book swap system can be split into three smaller sub-problems: Input, Process, and Output. The Input stage collects the book details and student requests. The Process stage searches the stored book list for possible matches. The Output stage displays the results – either a list of available books or a swap match notification.
计算思维从分解开始。图书交换系统可以拆分成三个较小的子问题:输入、处理和输出。输入阶段收集图书信息与学生请求。处理阶段在已存储的书籍列表中搜索可能的匹配。输出阶段展示结果——要么是可用书籍清单,要么是交换匹配通知。
- Input: a student enters their ID, the book title they are giving away, or the book they want.
- Process: store book data in a list; compare a wanted book against all offered books.
- Output: display 'Match found! Student A can swap with Student B' or 'No match yet'.
- 输入:学生输入自己的学号、他们送出的书名,或者他们想要的书名。
- 处理:将书籍数据储存在列表中;把想要的书与所有送出的书进行比对。
- 输出:显示“找到匹配!学生A可以与学生B交换”或者“尚未匹配”。
4. Pattern Recognition – Spotting Similarities | 模式识别——发现相似之处
We now ask: have we seen similar problems before? Yes — this system works like a simple search engine or a library catalogue. When you search for a book, the program must look through every item in a list until it finds a matching title. This is exactly the same pattern as looking up a contact in a phone book or finding a file on your computer.
我们现在问:以前见过类似的问题吗?当然——这个系统就像一个简单的搜索引擎或图书馆目录。当你搜索一本书时,程序必须遍历列表中的每一项,直到找到匹配的书名。这和翻阅电话簿查找联系人或者在电脑上查找文件是完全一样的模式。
Recognising this pattern allows us to reuse a simple searching technique called linear search. We also notice that the 'offered books' list grows and shrinks as swaps happen, which mirrors the behaviour of a stack or queue. However, for a Year 8 solution, a basic list is perfectly adequate.
识别出这个模式后,我们就可以重用一种叫做线性搜索的简单搜索技术。我们还注意到,“送出的书籍”列表会随着交换的发生而增减,这模仿了栈或队列的行为。不过,对 Year 8 的解决方案而言,一个基本的列表就完全够用了。
5. Abstraction – Focusing on What Matters | 抽象——专注重要信息
In real life, a book has many attributes: title, author, number of pages, colour of the cover, condition, and even scent. For our swap system, we do not need all that detail. Abstraction means modelling only the essential information. We decide to store just three fields: the book title, the student ID of the owner, and a status (available or swapped).
在现实生活中,一本书有很多属性:书名、作者、页数、封面颜色、状况甚至气味。对于我们的交换系统,我们并不需要所有这些细节。抽象意味着只对必要的信息进行建模。我们决定只储存三个字段:书名、所有者的学号和状态(可交换或已交换)。
Here is how we can represent the book data in a simplified table:
我们可以用下面这个简化的表格来表示书籍数据:
| Book Title | Student ID | Status |
|---|---|---|
| The Iron Man | S103 | Available |
| Matilda | S207 | Available |
| Holes | S154 | Swapped |
By removing unnecessary detail, we keep the problem simple and avoid being overwhelmed. This is a crucial skill in programming and indeed in any problem-solving activity.
通过移除不必要的细节,我们让问题保持简单,避免被无关信息淹没。这是编程乃至任何问题解决活动中的一项关键技能。
6. Algorithm Design – Step-by-Step Solution | 算法设计——分步解决方案
An algorithm is a precise set of instructions to solve a problem. For the swap system, we will write two algorithms: one to add a book to the offered list, and one to search for a wanted book. Both will be expressed before we think about a specific programming language.
算法是解决一组问题的精确指令集。对于交换系统,我们将写出两个算法:一个用于把书添加到送书清单,另一个用于搜索想要的书。在考虑具体的编程语言之前,就要先把它们表达出来。
Let us start with the 'Add a book' algorithm:
- Ask the student to enter their ID.
- Ask the student to enter the title of the book they want to give away.
- Create a new record with the title, ID, and status 'Available'.
- Add this record to the end of the offered books list.
- Display a confirmation message.
我们先来看“添加书籍”算法:
- 要求学生输入学号。
- 要求学生输入他们要送出的书名。
- 创建一个包含书名、学号和状态“可交换”的新记录。
- 将该记录添加到送书列表的末尾。
- 显示一条确认信息。
The 'Search for a book' algorithm is slightly more interesting because it uses a loop and a condition:
- Ask the searcher to enter the wanted book title.
- Set a pointer to the start of the offered books list.
- Repeat until the end of the list:
- Compare the current book title with the wanted title.
- If they match AND the status is 'Available', then display 'Match found with Student [ID]' and change the status to 'Swapped'. Stop the algorithm.
- Otherwise, move to the next record.
- If the loop finishes without a match, display 'No book found'.
“搜索书籍”算法则更有趣一些,因为它用到了循环和条件判断:
- 要求搜索者输入想要的书名。
- 将指针指向送书列表的起始位置。
- 重复执行直到列表末尾:
- 将当前的书名与想要的书名进行比较。
- 如果匹配并且状态为“可交换”,则显示“找到匹配,与学生 [学号]”并将状态改为“已交换”。停止算法。
- 否则,移到下一条记录。
- 如果循环结束后仍未匹配,则显示“未找到该书”。
7. Writing Pseudocode – Bridging to Code | 编写伪代码——通向代码的桥梁
Pseudocode allows us to write algorithms in a way that resembles real code but remains easy for humans to read. We do not need to worry about exact syntax for loops or semicolons yet. Here is the search algorithm in pseudocode:
伪代码让我们能够以接近真实代码但又便于人类阅读的方式来书写算法。我们暂时不需要担心循环的确切语法或分号。以下是搜索算法的伪代码:
INPUT wantedBook
FOR each record IN offeredBooks
IF record.title = wantedBook AND record.status = 'Available' THEN
DISPLAY 'Match found with Student ', record.studentID
record.status = 'Swapped'
STOP
ENDIF
ENDFOR
DISPLAY 'No book found'
This pseudocode uses a FOR loop to go through each item, an IF...THEN statement to check conditions, and INPUT and DISPLAY for interaction. Notice that we combined logical operators (AND) to check both the title match and the availability. Writing pseudocode first helps us avoid syntax errors when we later translate it into Python or Scratch.
这段伪代码使用 FOR 循环遍历每一项,使用 IF...THEN 语句检查条件,并使用 INPUT 和 DISPLAY 进行交互。注意我们使用逻辑运算符(AND)来同时检查书名匹配和可借状态。先写伪代码有助于我们在之后用 Python 或 Scratch 实现时避免语法错误。
8. Flowchart Visualisation – Seeing the Logic | 流程图可视化——看清逻辑
A flowchart is another powerful tool to represent an algorithm. It uses standard symbols: oval for start/stop, parallelogram for input/output, diamond for decision, and rectangle for process. Visualising the search algorithm as a flowchart can reveal potential flaws, such as forgetting to update the book status after a swap.
流程图是另一种强大的算法表达工具。它使用标准符号:椭圆代表开始/结束,平行四边形代表输入/输出,菱形代表判断,矩形代表处理。将搜索算法可视化为流程图可以揭示潜在的缺陷,比如忘记在交换后更新书籍状态。
Imagine a flowchart that begins with 'Input wantedBook', then enters a decision diamond: 'Any more records to check?'. If yes, the next diamond asks 'Title match and Available?'. A true path leads to outputs and status change, then an end. A false path loops back. The final path from 'Any more records?' being false leads directly to 'No book found'. This clarity reduces the chance of an infinite loop and makes debugging easier.
想象这样一个流程图:从“输入 wantedBook”开始,然后进入一个判断菱形:“还有更多记录要检查吗?”如果是,下一个菱形询问“书名匹配且为可交换吗?”为真的路径通向输出和状态更改,然后结束。为假的路径返回循环。而“还有更多记录吗?”为假的路径直接通向“未找到书”。这种清晰的表达降低了无限循环的机会,也使调试更加容易。
9. Testing and Debugging – Making It Work | 测试与调试——让它正常运行
Even the best algorithm needs testing. We will test our logic using a table of test cases. Consider the offered books list in Section 5. We will run the search algorithm with different inputs and predict the output. This is called a dry run.
即使是最好的算法也需要测试。我们将使用测试用例表来测试我们的逻辑。考虑第5节中的送书列表。我们将用不同的输入运行搜索算法,并预测输出。这就叫做干运行。
| Test Case | wantedBook | Expected Output |
|---|---|---|
| 1 (Normal match) | Matilda | Match found with Student S207 |
| 2 (Already swapped) | Holes | No book found (or skip swapped record) |
| 3 (Not in list) | Wonder | No book found |
| 4 (Case difference) | matilda | No match unless we ignore case |
Test Case 4 reveals a real-world bug: case sensitivity. The search would fail if a user types 'matilda' instead of 'Matilda'. We can debug this by converting both the input and stored titles to all capitals or all lowercase before comparing. This is a classic example of how testing improves program reliability.
测试用例4揭示了一个真实的缺陷:大小写敏感性。如果用户输入“matilda”而不是“Matilda”,搜索就会失败。我们可以通过将输入和储存的书名在比较前都转换为全大写或全小写来调试。这就是测试如何提高程序可靠性的经典例子。
10. Evaluation and Reflection – What Have We Learned? | 评估与反思——我们学到了什么?
After completing the design, we look back and evaluate our solution. The book swap system meets the librarian's core requirements: it stores offered books, searches for wanted titles, and notifies a match. It is simple, uses a linear list, and protects student identities by using ID numbers. However, we can also think about limitations.
完成设计后,我们回顾并评估解决方案。这个图书交换系统满足了图书馆老师的核心需求:存储送出的书籍、搜索想要的书籍并通知匹配。它很简单,使用了线性列表,并通过使用学号来保护学生身份。不过,我们也可以思考它的局限性。
One limitation is that the system only allows one-to-one swaps. A more advanced version could handle three-way swaps or let students build a wishlist. Another is that the data disappears when the program stops – we have not added file storage. Despite these, the project demonstrates every stage of the problem-solving lifecycle: understanding the problem, decomposition, pattern recognition, abstraction, algorithm design, and testing. These are the building blocks of all great software.
一个局限是该系统只允许一对一的交换。更高级的版本可以处理三方交换,或者让学生建立愿望清单。另一个局限是程序停止时数据就会消失——我们没有加入文件存储功能。尽管如此,这个项目展示了问题解决生命周期的每一个阶段:理解问题、分解、模式识别、抽象、算法设计和测试。这些是所有伟大软件的基石。
Published by TutorHao | Computer Science Revision Series | aleveler.com
更多咨询请联系16621398022(同微信)

或截图后用「扫一扫 → 相册」选择本图