Year 10 Edexcel Computer Science: Case Study in Action | 爱德思10年级计算机:案例分析实战演练

📚 Year 10 Edexcel Computer Science: Case Study in Action | 爱德思10年级计算机:案例分析实战演练

A case study is one of the most powerful ways to bring the abstract topics of computer science to life. In your Edexcel Year 10 course, you will often be asked to analyse a real-world problem, break it down into manageable parts, design a solution, and then develop and test a program. This walkthrough takes you through a complete library book-loan system case study, demonstrating how to apply computational thinking, pseudocode, flowcharts, data structures, and testing strategies step by step.

案例分析是将计算机科学的抽象主题变得生动的最有力方式之一。在爱德思10年级课程中,你常常会被要求分析一个真实世界的问题,将其分解为可管理的部分,设计解决方案,然后开发并测试一个程序。本次演练将带你完成一个完整的图书馆图书借阅系统案例分析,逐步展示如何应用计算思维、伪代码、流程图、数据结构和测试策略。


1. Understanding the Case Study Scenario | 理解案例情景

A local library needs a simple program to manage its book loans. The library stores books, each with a unique ID, title, and author. Members of the library can borrow books, but they may not have more than three books on loan at any one time. The system must allow the librarian to add new books, register members, process borrowing and returning of books, and display all books currently borrowed by a specific member. The scenario includes constraints: a book cannot be borrowed if it is already on loan, and a member who already has three books must return one before borrowing another.

一家当地图书馆需要一个简单的程序来管理图书借阅。图书馆存储图书,每本书有唯一的ID、标题和作者。图书馆会员可以借阅书籍,但任何时候不得同时借阅超过三本书。系统必须允许图书管理员添加新书、注册会员、处理借阅和归还,以及显示某个特定会员当前借阅的所有书籍。该情景包含约束条件:如果一本书已被借出,则不能再借出;如果一个会员已有三本书,则必须归还一本后才能再借另一本。

Before diving into design, we must identify the key entities, actions, and boundaries. The entities are Book, Member, and Loan. Actions include addBook, registerMember, borrowBook, returnBook, and listMemberBooks. Boundaries involve the maximum loan limit and book availability. This thorough understanding ensures no detail is missed.

在投入设计之前,我们必须识别关键实体、操作和边界。实体是图书、会员和借阅。操作包括添加图书、注册会员、借书、还书和列出会员所借图书。边界涉及最大借阅限额和图书可用性。这种透彻的理解确保没有遗漏任何细节。


2. Identifying Requirements (Functional and Non-functional) | 识别需求(功能性与非功能性)

Functional requirements describe what the system should do. For this library system, functional requirements include: the ability to add a new book with an ID, title, and author; to register a new member with a unique membership number; to borrow a book by linking a member and a book provided the book is available and the member has fewer than three loans; to return a book by breaking that link; and to display a member’s current loans. Non-functional requirements relate to how the system performs: the interface should be text-based and easy to use, the system must respond quickly, and the data should be stored in memory during a session (no database needed).

功能性需求描述系统应该做什么。对于这个图书馆系统,功能性需求包括:能够添加一本带有ID、标题和作者的新书;能够注册一个带有唯一会员编号的新会员;能够借阅一本书,将会员与书籍关联起来,前提是该书可借且会员的借阅数少于三本;能够归还一本书以解除关联;能够显示会员当前的借阅情况。非功能性需求与系统如何运行有关:界面应为文本形式且易于使用,系统必须快速响应,会话期间数据存储在内存中(无需数据库)。

Edexcel mark schemes often reward clear separation of these requirements. Defining them early helps you design a focused solution and avoid scope creep.

爱德思评分标准通常奖励清晰区分这些需求的做法。尽早定义它们有助于你设计出重点突出的解决方案,并避免范围蔓延。


3. Decomposition and Abstraction | 分解与抽象

Decomposition means breaking the complex problem into smaller, more manageable sub-problems. We can decompose the library system into modules: book management, member management, loan processing, and display utilities. Each module can be tackled independently.

分解意味着将复杂问题拆分为更小、更易于管理的子问题。我们可以将图书馆系统分解为几个模块:图书管理、会员管理、借阅处理和显示工具。每个模块可以独立应对。

Abstraction is about focusing on the essential information and ignoring irrelevant details. For a book, we need id, title, author – but we don’t need the number of pages or publication year. For a member, we need membership number, name, and a list of current loan references. The process of borrowing can be abstracted as a function that takes a book ID and a member ID, checks constraints, and updates both book status and member’s loan list.

抽象就是聚焦于必要信息,忽略无关细节。对于一本书,我们需要ID、标题、作者——但不需要页数或出版年份。对于会员,我们需要会员编号、姓名和当前借阅引用的列表。借阅过程可以抽象为一个函数,该函数接受图书ID和会员ID,检查约束条件,并更新图书状态和会员的借阅列表。

These two cornerstones of computational thinking reduce complexity and lead to cleaner code.

计算思维的这两大基石降低了复杂性,并带来更清晰的代码。


4. Designing the Solution: Flowcharts | 解决方案设计:流程图

Flowcharts provide a visual representation of algorithms. Here is a simplified flowchart for the borrow process. Start, input bookID and memberID, check if book exists and is available; if not, output error. Then check if member exists and loan count < 3; if not, output error. If both checks pass, set book status to 'on loan', add bookID to member's list, increment loan count, and output success.

流程图提供了算法的可视化表示。以下是借阅流程的简化流程图。开始,输入bookID和memberID,检查书籍是否存在且可借;如果不是,输出错误。然后检查会员是否存在且借阅数小于3;如果不是,输出错误。如果两项检查都通过,将书籍状态设为“已借出”,将bookID添加到会员列表,增加借阅计数,并输出成功。

While we cannot draw the flowchart here, you can imagine the standard shapes: ovals for start/end, parallelograms for input/output, diamonds for decisions, and rectangles for processes. Using a flowchart before writing pseudocode helps you spot logic errors early.

虽然我们无法在此绘制流程图,但你可以想象标准形状:椭圆表示开始/结束,平行四边形表示输入/输出,菱形表示决策,矩形表示过程。在编写伪代码之前使用流程图有助于及早发现逻辑错误。


5. Pseudocode for Key Processes | 关键过程的伪代码

Edexcel expects you to write clear, structured pseudocode. Below is pseudocode for the main borrow function, using keywords like IF, THEN, ELSE, WHILE, and ENDIF.

爱德思期望你写出清晰、结构化的伪代码。以下是主借阅函数的伪代码,使用了诸如IF、THEN、ELSE、WHILE和ENDIF等关键字。

PROCEDURE borrowBook(bookID, memberID)
  IF bookExists(bookID) = FALSE THEN
    OUTPUT “Book not found”
    RETURN
  ENDIF
  IF bookAvailable(bookID) = FALSE THEN
    OUTPUT “Book already on loan”
    RETURN
  ENDIF
  IF memberExists(memberID) = FALSE THEN
    OUTPUT “Member not found”
    RETURN
  ENDIF
  IF memberLoanCount(memberID) >= 3 THEN
    OUTPUT “Loan limit reached”
    RETURN
  ENDIF
  setBookStatus(bookID, “on loan”)
  addBookToMember(memberID, bookID)
  OUTPUT “Book borrowed successfully”
ENDPROCEDURE

过程 borrowBook(bookID, memberID)
  如果 bookExists(bookID) = FALSE 那么
    输出 “未找到图书”
    返回
  结束如果
  如果 bookAvailable(bookID) = FALSE 那么
    输出 “图书已借出”
    返回
  结束如果
  如果 memberExists(memberID) = FALSE 那么
    输出 “未找到会员”
    返回
  结束如果
  如果 memberLoanCount(memberID) >= 3 那么
    输出 “已达借阅上限”
    返回
  结束如果
  setBookStatus(bookID, “已借出”)
  addBookToMember(memberID, bookID)
  输出 “图书借阅成功”
结束过程

This structured English is precise and exam-ready. Indentation clarifies the logic flow, which is crucial for Edexcel examiners.

这种结构化的英语表达精确且适用于考试。缩进使逻辑流清晰,这对爱德思考官来说至关重要。


6. Data Structures: Arrays and Records | 数据结构:数组与记录

To implement the system, we need efficient data structures. A record (or structure) can define a Book: ID (integer), title (string), author (string), status (string – ‘available’ or ‘on loan’). Similarly, a Member record has: memberID (integer), name (string), loans (array of integers, initialised empty), loanCount (integer).

为了实现系统,我们需要高效的数据结构。一个记录(或结构)可以定义图书:ID(整数)、标题(字符串)、作者(字符串)、状态(字符串——“可借”或“已借出”)。类似地,会员记录包含:memberID(整数)、姓名(字符串)、借阅列表(整数数组,初始为空)、借阅计数(整数)。

We can then store multiple books in an array `books[]` and members in `members[]`. Using arrays makes it easy to traverse and search. For instance, finding a book by ID requires a linear search through the books array. As no deletions are expected, we can simply use arrays with a fixed large size, but dynamic arrays or lists are acceptable in pseudocode.

然后,我们可以将多本书存储在数组 books[] 中,将多个会员存储在 members[] 中。使用数组便于遍历和搜索。例如,通过ID查找图书需要对图书数组进行线性搜索。由于不需要删除操作,我们可以简单地使用具有固定较大容量的数组,但在伪代码中动态数组或列表也是可接受的。

Choosing the right data structure early avoids messy code later. Records group related data, and arrays manage collections – both are heavily featured in the Edexcel specification.

尽早选择正确的数据结构可以避免后续代码混乱。记录将相关数据分组,数组则管理集合——两者在爱德思大纲中都有重要地位。


7. Algorithm Spotlight: Searching and Sorting | 算法聚焦:搜索与排序

Our library system frequently needs to find a book by its ID. Linear search is a straightforward algorithm. We iterate through the `books` array, compare the ID, and return the index if found, otherwise -1. It is efficient enough for a small library. Pseudocode:

我们的图书馆系统经常需要根据ID查找图书。线性搜索是一种直接的算法。我们遍历 books 数组,比较ID,如果找到则返回索引,否则返回-1。对于一个小型图书馆,这已经足够高效。伪代码:

FUNCTION findBookIndex(id)
FOR i FROM 0 TO books.length-1
  IF books[i].ID = id THEN RETURN i
ENDFOR
RETURN -1
ENDFUNCTION

函数 findBookIndex(id)
对于 i 从 0 到 books.length-1
  如果 books[i].ID = id 那么 返回 i
结束对于
返回 -1
结束函数

Sorting may be needed if we want to list members alphabetically or display books by title. Bubble sort is simple and examinable. Understanding both linear search and bubble sort is essential for tracing algorithms in the exam.

如果我们要按字母顺序列出会员或按标题显示图书,排序可能很有必要。冒泡排序简单且是考试内容。理解线性搜索和冒泡排序对于在考试中跟踪算法至关重要。

Search Type Best for Worst-case time
Linear Search Unsorted small dataset O(n)
Binary Search Sorted dataset O(log n)

表格内容:(搜索类型、最适用于、最坏情况时间) 线性搜索适用于未排序的小数据集 O(n);二分搜索适用于已排序数据集 O(log n)。虽然二分搜索更高效,但本案例中数组未排序且需要频繁更新,因此线性搜索更简单可靠。


8. Developing the Program (Code Skeleton) | 开发程序(代码骨架)

Below is a Python-like skeleton that mirrors the design. Not all functions are implemented in full, but the structure reflects the decomposition.

以下是一个类似Python的骨架,反映了设计。并未实现所有函数,但结构体现了分解思路。


class Book:
  def __init__(self, id, title, author):
    self.id = id
    self.title = title
    self.author = author
    self.status = ‘available’

books = []
members = []

def add_book(book):
  books.append(book)

def borrow_book(book_id, member_id):
  … # use findBookIndex and validation


class Book:
  def __init__(self, id, title, author):
    self.id = id
    self.title = title
    self.author = author
    self.status = ‘available’

books = []
members = []

def add_book(book):
  books.append(book)

def borrow_book(book_id, member_id):
  … # 使用 findBookIndex 和验证

Note how the code matches the flowcharts and pseudocode. Using functions for each action keeps the program modular. The `self.status` tracks book availability, and the member class would hold a list of borrowed book IDs. This alignment between design and implementation is a key Edexcel skill.

请注意代码如何与流程图和伪代码相匹配。为每个操作使用函数可以保持程序的模块化。self.status 跟踪图书可用性,而会员类将持有一个借阅图书ID的列表。设计与实现之间的这种对齐是一项关键的爱德思技能。


9. Testing: Normal, Boundary and Erroneous Data | 测试:正常、边界和异常数据

Testing is not an afterthought; it is built into the development process. We plan test cases for normal data (a member with 0 books borrowing an available book), boundary data (a member with 2 books trying to borrow a third – success; a member with 3 books trying to borrow – failure), and erroneous data (invalid book ID, invalid member ID, negative numbers).

测试不是事后才考虑的事情;它已融入开发过程。我们为正常数据(拥有0本书的会员借阅一本可借的书)、边界数据(拥有2本书的会员尝试借第三本——成功;拥有3本书的会员尝试借书——失败)和异常数据(无效图书ID、无效会员ID、负数)规划测试用例。

Test ID Input Expected outcome
T1 bookID=101, memberID=1 (member has 0 loans, book available) Success message; book status changed; member loan count 1
T2 bookID=101 again (already on loan) Error: Book already on loan
T3 memberID=1 with loan count=3, valid book Error: Loan limit reached
T4 bookID=999 (non-existent) Error: Book not found

A trace table can also be used to follow variable values through an algorithm, helping to verify logic during both manual tests and exam questions.

测试ID T1:bookID=101, memberID=1 (会员有0本书,书可借) 预期成功,书状态改变,会员借阅计数1。T2:再次bookID=101(已借出)预期错误。T3:memberID=1 借阅计数=3 有效书,预期错误。T4:bookID=999 不存在,预期错误。跟踪表也可用于跟踪算法中变量的值,有助于在手动测试和考题中验证逻辑。


10. Evaluation and Reflection | 评估与反思

Every solution has strengths and weaknesses. This system works well for a small library with few concurrent requests. It is simple to understand and easy to modify. However, it lacks persistent storage, so all data is lost when the program closes. The linear search will become slow if the collection grows to thousands of books. To improve, we could add file handling to save data and replace the array of books with a dictionary (keyed by ID) for constant-time lookups.

每个解决方案都有优点和缺点。这个系统对于并发请求较少的小型图书馆运行良好。它易于理解,容易修改。然而,它缺少持久化存储,因此程序关闭时所有数据都会丢失。如果馆藏增长到数千本书,线性搜索将变慢。为了改进,我们可以添加文件处理来保存数据,并将书的数组替换为字典(以ID为键)以实现常数时间查找。

Reflecting on the design process consolidates your learning for the Edexcel exam, where you may be asked to critique your own solution and suggest enhancements. Always consider efficiency, usability, and maintainability.

对设计过程的反思可以巩固你在爱德思考试中的学习,考试中可能会要求你批判自己的解决方案并提出改进建议。要始终考虑效率、可用性和可维护性。


Published by TutorHao | Computer Science Revision Series | aleveler.com

更多咨询请联系16621398022(同微信)

Comments

屏轩国际教育cambridge primary/secondary checkpoint, cat4, ukiset,ukcat,igcse,alevel,PAT,STEP,MAT, ibdp,ap,ssat,sat,sat2课程辅导,国外大学本科硕士研究生博士课程论文辅导

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from aleveler.com

Subscribe now to keep reading and get access to the full archive.

Continue reading