📚 Case Study Practical Exercise | 案例分析实战演练
In the Eduqas GCSE Computer Science specification, case study exercises bring together theory and practical skills by analysing a real‑world scenario. This article walks through a complete case study of a "School Library Management System", demonstrating how to identify requirements, design data structures, create algorithms, address security concerns, and plan testing — all essential components of the Year 10 curriculum.
在Eduqas GCSE计算机科学大纲中,案例分析练习通过分析一个真实场景将理论与实践技能结合起来。本文以“学校图书馆管理系统”为例,完整演练如何确定需求、设计数据结构、编写算法、处理安全问题以及规划测试——所有这些都属于Year 10课程的核心内容。
1. Understanding the Case Study Scenario | 理解案例场景
Our case study is a secondary school that needs a digital library system. Currently, books are managed with paper cards and a handwritten log. Students borrow books by writing their name and the book title. Librarians find it time‑consuming to check availability, track overdue items, and generate reports. The school wants a program that stores book and borrower data, allows searching, processes loans and returns, and alerts users about due dates.
我们的案例是一所需要数字化图书馆系统的中学。目前图书靠纸质卡片和手写记录来管理。学生借书时写下姓名和书名。图书管理员觉得检查库存、追踪逾期图书、生成报告都很费时。学校希望开发一个程序,能存储图书和借阅者数据、支持搜索、办理借还手续,并对到期日进行提醒。
2. Identifying Stakeholders and Requirements | 确定利益相关者与需求
The main stakeholders are students, the librarian, and the school administration. Students need a simple interface to search books and view their borrowing history. The librarian needs to add new books, record loans and returns, and view overdue lists. The school administration requires monthly borrowing statistics. Functional requirements include: add/remove books, register borrowers, issue/return books, search by title/author/ISBN, and calculate fines for late returns. Non‑functional requirements include a responsive interface, secure login, and the ability to store at least 10,000 records.
主要的利益相关者是学生、图书管理员和学校管理层。学生需要简单的界面来搜索图书、查看借阅历史。图书管理员需要添加新书、记录借出和归还、查看逾期清单。学校管理层要求月度借阅统计数据。功能性需求包括:增删图书、注册借阅者、借书/还书、按书名/作者/ISBN搜索、计算逾期罚款。非功能性需求包括界面响应快、安全登录、能够存储至少一万条记录。
3. Data Representation and Storage | 数据表示与存储
We must decide how data will be represented inside the program. Books can be represented as records with fields: BookID (integer), Title (string), Author (string), ISBN (string), PublicationYear (integer), and Status (available/on loan). Borrowers are records with BorrowerID, Name, YearGroup, and Class. A loan transaction links a BorrowerID and BookID, along with IssueDate and DueDate. Dates can be stored as strings in DD/MM/YYYY format or as a number of days since a fixed date. For searching and indexing, arrays of records or CSV files are suitable for GCSE‑level implementation.
我们必须决定数据在程序内部的表示方式。图书可表示为记录,字段包括:BookID(整数)、Title(字符串)、Author(字符串)、ISBN(字符串)、PublicationYear(整数)和 Status(在库/借出)。借阅者是包含 BorrowerID、Name、YearGroup 和 Class 的记录。借阅交易将 BorrowerID 与 BookID 关联,并包括 IssueDate 和 DueDate。日期可以用 DD/MM/YYYY 格式的字符串存储,也可存储为距离固定日期的天数。对于搜索和索引,记录数组或 CSV 文件适合 GCSE 级别的实现。
4. Designing the Database | 设计数据库
Using a flat‑file approach, we can maintain three CSV files: books.csv, borrowers.csv, and loans.csv. Each file’s first row contains field names. An alternative is a relational database with tables linked by primary and foreign keys. For a GCSE case study, flat files are often acceptable, but we should be able to explain the benefits of a relational model — such as reducing data redundancy and allowing complex queries. Below is a possible entity‑relationship outline:
使用平面文件方式,我们可以维护三个 CSV 文件:books.csv、borrowers.csv 和 loans.csv。每个文件第一行包含字段名。另一种方式是采用关系型数据库,通过主键和外键关联表。对于 GCSE 案例分析,平面文件通常可以接受,但我们应该能够解释关系模型的优点——例如减少数据冗余、支持复杂查询。下面是一个可能的实体关系大纲:
| Table | Primary Key | Foreign Key |
|---|---|---|
| Books | BookID | — |
| Borrowers | BorrowerID | — |
| Loans | LoanID | BookID, BorrowerID |
5. Algorithms and Data Processing | 算法与数据处理
Several algorithms are needed. To search for a book by title, we can use a linear search through the array of book records because the dataset is relatively small. When issuing a book, the algorithm must check the book’s status, create a new loan record, set the due date (typically 14 days from today), and update the book’s status to ‘on loan’. For overdue identification, we compare the current date with the Loan table’s DueDate and list records where DueDate < CurrentDate. Sorting the results by DueDate can be achieved with a bubble sort or insertion sort — GCSE candidates are expected to implement simple sorting algorithms.
需要用到几个算法。按书名搜索图书时,由于数据集相对较小,可以对图书记录数组使用线性搜索。办理借书时,算法必须检查图书状态、创建新的借阅记录、设定到期日(通常从今天起14天),并将图书状态更新为“已借出”。识别逾期图书时,我们将当前日期与 Loans 表中的 DueDate 进行比较,列出 DueDate < CurrentDate 的记录。按到期日排序可以通过冒泡排序或插入排序实现——GCSE考生应能实现简单的排序算法。
In pseudocode for searching:
搜索的伪码如下:
FUNCTION searchByTitle(searchTerm)
FOR i ← 0 TO LEN(books)-1
IF books[i].Title = searchTerm THEN
RETURN books[i]
ENDFOR
RETURN "Not found"
ENDFUNCTION
6. User Interface Design | 用户界面设计
The interface can be text‑based or graphical. A text‑based menu system is appropriate for early prototyping. The main menu might display options: 1. Search Book, 2. Borrow Book, 3. Return Book, 4. View Overdue, 5. Add New Book, 6. Exit. Each option calls a corresponding subroutine. For the student portal, a simplified menu could hide management functions behind a password‑protected admin area. Usability considerations include clear input prompts, error messages, and displaying results in a readable format. A design with a consistent layout and logical navigation improves the user experience.
界面可以是基于文本的或图形化的。基于文本的菜单系统适合早期原型设计。主菜单可以显示选项:1. 搜索图书,2. 借书,3. 还书,4. 查看逾期,5. 添加新书,6. 退出。每个选项调用相应的子程序。对于学生门户,可以简化菜单,将管理功能隐藏在密码保护的管理员区域后面。可用性方面的考虑包括清晰的输入提示、错误消息以及以可读格式显示结果。具有一致布局和逻辑导航的设计可以提升用户体验。
7. Security and Ethical Considerations | 安全与道德考量
Security is crucial because borrower information is personal data. The system should require a password to access administrative functions. A simple log‑in mechanism can store hashed passwords (e.g., using a simple hash as a demonstration). Additionally, input sanitisation must prevent injection attacks — for example, checking that a number is actually entered when expecting a year. Ethically, the system must respect data protection principles: only collect necessary data, store it securely, and not share it without consent. Students and parents should be informed about what data is stored and how it is used.
安全至关重要,因为借阅者信息属于个人数据。系统应要求输入密码才能访问管理功能。一个简单的登录机制可以存储散列处理后的密码(例如使用简单哈希作为演示)。此外,输入清理必须防止注入攻击——例如,在需要年份的地方检查输入确实是数字。道德方面,系统必须遵守数据保护原则:只收集必要数据,安全存储,未经同意不对外分享。学生和家长应被告知存储了哪些数据以及如何使用这些数据。
8. Testing Strategies | 测试策略
Testing should be planned throughout development. Unit tests verify individual subroutines — for example, a test that checks whether searchByTitle returns the correct book when given an exact match, and returns “Not found” for a missing title. Integration tests ensure that modules work together, such as issuing a book updates both the Loans file and the book status. Boundary tests are important: what happens if someone tries to borrow a book that is already on loan? What if the borrower ID does not exist? A test plan document would list test ID, description, input data, expected result, and actual result.
测试应贯穿整个开发过程。单元测试验证单个子程序——例如,测试 searchByTitle 在精确匹配时返回正确的图书记录,在找不到书名时返回“Not found”。集成测试确保模块协同工作,例如借出一本书应同时更新 Loans 文件和图书状态。边界测试也很重要:如果有人试图借一本已经借出的书会怎样?如果借阅者 ID 不存在呢?测试计划文档应列出测试编号、描述、输入数据、预期结果和实际结果。
| Test ID | Description | Input | Expected |
|---|---|---|---|
| T01 | Search existing title | "Animal Farm" | Book record returned |
| T02 | Search non‑existing title | "xyz123" | "Not found" |
| T03 | Borrow already loaned book | BookID=5 (on loan) | Error message |
9. Evaluation and Improvements | 评估与改进
After implementing the prototype, we should evaluate how well it meets the requirements. Strengths might include a straightforward menu‑based interaction, reliable data storage with CSV files, and successful overdue detection. Weaknesses could be the limited search capability (only exact title matches) and the lack of a graphical interface. Possible improvements include implementing a partial‑string search, adding a barcode scanner interface to speed up book issuing, or migrating to an SQL database for better data integrity and concurrent access. Discussing these changes demonstrates high‑level analytical skills.
实现原型后,我们应评估它在多大程度上满足了需求。优点可能包括直观的菜单式交互、可靠的 CSV 文件数据存储以及成功的逾期检测。弱点可能是搜索功能有限(只支持精确标题匹配)以及缺少图形界面。可能的改进包括实现部分字符串搜索、添加条形码扫描接口以加快借书速度,或者迁移到 SQL 数据库以提高数据完整性和支持并发访问。讨论这些改进能展示高阶分析能力。
10. Extending the System | 扩展系统
Beyond the core functionality, extensions could include a reservation system where students can reserve a book that is currently on loan. This requires a new data structure, perhaps a queue for each book. Another extension is sending automatic email reminders three days before the due date — this would involve using an SMTP library or simulating the feature with console messages. Finally, generating graphical charts of monthly borrowing trends could add value for the school administration. Each extension must be analysed for its impact on the existing design and potential ethical issues, such as collecting email addresses.
在核心功能之外,扩展可以包括预约系统,让学生可以预约当前已借出的书。这需要新的数据结构,也许每本书对应一个队列。另一个扩展是在到期日前三天发送自动邮件提醒——这涉及使用 SMTP 库或通过控制台消息模拟该功能。最后,为学校管理层生成月度借阅趋势的图形化图表也有价值。每个扩展都必须分析其对现有设计的影响以及潜在的道德问题,例如收集电子邮件地址。
Published by TutorHao | Computer Science Revision Series | aleveler.com
更多咨询请联系16621398022(同微信)

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