📚 Year 12 OCR Computer Science: Case Study Practical Walkthrough | Year 12 OCR 计算机:案例分析实战演练
This article takes you through a complete case study for the OCR Year 12 Computer Science specification, illustrating how to apply computational thinking, algorithm design, and systems analysis to a real-world scenario. By working through a library book management system, you will see exactly how to break down a problem, design data structures, craft efficient algorithms, and address legal and ethical concerns – all skills essential for exam success.
本文将带你完整演练一个符合 OCR Year 12 计算机科学大纲的案例,展示如何将计算思维、算法设计和系统分析应用于现实场景。通过一个图书馆图书管理系统,你将看到如何分解问题、设计数据结构、构建高效算法,并应对法律与道德问题——这些都是考试成功所必需的核心技能。
1. Understanding the Scenario | 理解场景
A school librarian currently manages book loans, returns, and overdue fines using paper records and Excel spreadsheets. The process is error-prone, slow, and makes it difficult to generate reports on popular titles or track overdue items efficiently. The headteacher has requested a dedicated software system that can be accessed from the library computer and eventually via a web portal for students to search the catalogue from home.
某学校图书管理员目前使用纸质记录和 Excel 电子表格管理图书借阅、归还和逾期罚款。该流程容易出错、速度慢,而且难以高效生成热门书籍报告或追踪逾期项目。校长要求开发一个专用软件系统,可从图书馆计算机访问,并最终通过网页门户让学生在家检索馆藏目录。
The system must store information about books, members (students and staff), and loans. It should allow librarians to add new books, register members, issue and return books, and calculate fines automatically. Students need a simple search interface to find books by title, author, or ISBN. Future enhancements might include reservation queues and integration with barcode scanners.
系统必须存储图书、会员(学生和教职工)和借阅信息。它应允许图书管理员添加新书、注册会员、借出和归还图书,并自动计算罚款。学生需要一个简单的搜索界面,按书名、作者或 ISBN 查找图书。未来的增强功能可能包括预约队列和条形码扫描器集成。
2. Stakeholders and Requirements | 利益相关者与需求
Identifying stakeholders is a vital first step in any system analysis. The primary stakeholders include: the librarian (who needs an efficient workflow), students (who want quick book searches and borrowing), teaching staff (who may borrow resources), and the school IT manager (who must ensure security, backup, and compatibility with the school network). Other indirect stakeholders are the headteacher (who funds the project) and the data protection officer (who must verify compliance with data protection law).
识别利益相关者是任何系统分析中至关重要的第一步。主要利益相关者包括:图书管理员(需要高效的工作流程)、学生(希望快速搜索图书并借阅)、教职工(可能借用资源)以及学校 IT 管理员(必须确保安全性、备份和与校园网络的兼容性)。其他间接利益相关者有校长(项目出资方)和数据保护官员(必须核实是否符合数据保护法)。
Gathering requirements can be done through interviews, observation of current procedures, and questionnaires with students. From these activities, a list of user needs emerges. For example, the librarian wants the system to reduce double-entry of data and to generate weekly overdue reports. Students want to see whether a book is available without visiting the library.
可通过访谈、观察当前流程和向学生发放问卷来收集需求。通过这些活动,一份用户需求清单得以浮现。例如,图书管理员希望系统减少数据重复录入,并能生成每周逾期报告。学生希望无需亲临图书馆就能查看某本书是否可借。
3. Functional and Non-Functional Requirements | 功能与非功能需求
Functional requirements define what the system must do. Non-functional requirements describe how the system performs its tasks. Both must be clearly documented before design begins.
功能需求定义了系统必须做什么。非功能需求描述了系统如何执行其任务。在开始设计之前,两者都必须明确记录。
Key functional requirements: The system shall allow librarians to add, update, and delete book records; register and manage member accounts; loan a book to a member and record the due date; accept a return and automatically calculate any fine if overdue; enable searching by title, author, ISBN, or keyword; and produce a report of all overdue items with member contact details.
关键功能需求:系统应允许图书管理员添加、更新和删除图书记录;注册并管理会员账户;将图书借给会员并记录应还日期;接受归还,如果逾期则自动计算罚款;支持按书名、作者、ISBN 或关键词搜索;并生成所有逾期项目的报告,附带会员联系方式。
Non-functional requirements include: the system must respond to a search query within 2 seconds under normal load; it must be accessible via a simple GUI; data must be backed up daily; only authorised staff may access the full management functions; and the system must run on the school’s existing Windows-based PCs without additional hardware.
非功能需求包括:系统在正常负载下必须在 2 秒内响应搜索查询;必须通过简单的图形用户界面访问;数据必须每日备份;只有授权员工才能访问全部管理功能;并且系统必须能在学校现有的 Windows 计算机上运行,无需额外硬件。
4. Data Modelling and Design | 数据建模与设计
After requirements are set, we design the data structures. A relational database approach suits this case because of the structured nature of the data and the relationships between books, members, and loans. Alternatively, the system could be built using simple text files, but for illustration we will use arrays of records (as often required in OCR pseudocode questions).
需求确定后,我们设计数据结构。关系型数据库方法非常适合这种情况,因为数据具有结构化特性,并且图书、会员与借阅之间存在关系。另一种方式是使用简单文本文件构建,但为了便于说明,我们将使用记录数组(OCR 伪代码题目中经常要求这样做)。
We define three main record types:
我们定义三种主要记录类型:
- Book: ID (integer), Title (string), Author (string), ISBN (string), Status (available/onloan)
- Member: MemberID (integer), Name (string), YearGroup (integer), Email (string), FinesOwed (real)
- Loan: LoanID (integer), BookID (integer), MemberID (integer), DateOut (string), DateDue (string), Returned (boolean)
- Book 记录:ID (整数),书名 (字符串),作者 (字符串),ISBN (字符串),状态 (可借/已借出)
- Member 记录:会员 ID (整数),姓名 (字符串),年级 (整数),邮箱 (字符串),所欠罚款 (实数)
- Loan 记录:借阅 ID (整数),图书 ID (整数),会员 ID (整数),借出日期 (字符串),应还日期 (字符串),是否归还 (布尔)
Arrays can hold these records. For example, library[100] is an array of Book records, members[500] an array of Member records, and loans[2000] an array of Loan records. Each array index acts as a simple primary key. In a database context, these would be tables with foreign keys linking Loan.BookID to Book.ID.
数组可以存储这些记录。例如,library[100] 是一个 Book 记录数组,members[500] 是 Member 记录数组,loans[2000] 是 Loan 记录数组。每个数组索引充当简单的主键。在数据库语境中,这些将成为表,并通过外键将 Loan.BookID 链接到 Book.ID。
5. Algorithm Design: Searching and Sorting | 算法设计:搜索与排序
Searching is central to the student catalogue. Let’s design a linear search and a binary search. Because books may not be sorted by title initially, a linear search is straightforward but O(n). To use binary search (O(log n)), we must first sort the array by the search key, for example alphabetically by title using bubble sort or insertion sort.
搜索是学生目录的核心。我们来设计一个线性搜索和一个二分搜索。由于图书初始时可能未按书名排序,线性搜索简单但复杂度为 O(n)。要使用二分搜索(O(log n)),我们必须先按搜索关键词排序,例如用冒泡排序或插入排序按书名首字母排序。
Below is pseudocode for a bubble sort on the library array by Title, followed by a binary search for a given title.
下面是对 library 数组按书名进行冒泡排序,然后对给定书名进行二分搜索的伪代码。
PROCEDURE bubbleSort(BYREF library: ARRAY[0:n-1] OF Book)
FOR i ← 0 TO n-2
FOR j ← 0 TO n-2-i
IF library[j].Title > library[j+1].Title THEN
temp ← library[j]
library[j] ← library[j+1]
library[j+1] ← temp
ENDIF
NEXT j
NEXT i
ENDPROCEDURE
此冒泡排序通过相邻比较将最大书名“冒泡”到末尾。外层循环控制趟数,内层循环执行比较和交换。这是 OCR 考试中必须掌握的经典排序算法。
After sorting, binary search can locate a title efficiently:
排序后,二分搜索可以高效定位书名:
FUNCTION binarySearch(library: ARRAY[0:n-1] OF Book, target: STRING) RETURNS INTEGER
low ← 0
high ← n-1
WHILE low ≤ high
mid ← (low + high) DIV 2
IF library[mid].Title = target THEN
RETURN mid
ELSE IF library[mid].Title < target THEN
low ← mid + 1
ELSE
high ← mid – 1
ENDIF
ENDWHILE
RETURN -1 // Not found
ENDFUNCTION
二分搜索通过反复将搜索区间一分为二来工作。它只能用于已排序数组,但效率远高于线性搜索。OCR 真题常要求你手写这样的伪代码并分析其复杂度。
6. User Interface and Prototyping | 用户界面与原型设计
A simple command-line prototype might be acceptable for early testing, but the final system should have a graphical user interface (GUI). For the librarian module, we could design a main menu with buttons: ‘Manage Books’, ‘Manage Members’, ‘Issue Book’, ‘Return Book’, ‘Overdue Report’. For the student catalogue, a single search box with a results list would suffice.
用于早期测试的简单命令行原型可能是可接受的,但最终系统应具备图形用户界面(GUI)。对于图书管理员模块,我们可以设计一个带有按钮的主菜单:“管理图书”、“管理会员”、“借出图书”、“归还图书”、“逾期报告”。对于学生目录,一个带结果列表的单一搜索框就足够了。
Prototyping helps to refine requirements early. A low-fidelity sketch on paper or a quick mock-up using a GUI builder can be shown to the librarian. Feedback might reveal that the ‘Issue Book’ screen needs to automatically look up member details from a barcode scan or that the search must support wildcards. Iterative prototyping prevents costly late changes.
原型设计有助于早期完善需求。在纸上绘制低保真草图或使用 GUI 构建器快速制作模型可以展示给图书管理员。反馈可能揭示出“借出图书”屏幕需要通过条形码扫描自动查找会员详情,或者搜索必须支持通配符。迭代原型设计可以避免后期代价高昂的变更。
For exam answers, you might be asked to sketch a user interface and explain navigation. Always label components clearly and justify design decisions in terms of usability principles (consistency, minimising memory load, clear feedback).
对于考试答案,你可能会被要求勾勒一个用户界面并解释导航流程。务必清晰标注组件,并根据可用性原则(一致性、减少记忆负担、清晰反馈)说明设计决策的理由。
7. Testing Strategy | 测试策略
A robust testing plan ensures the system meets requirements and is free from critical bugs. Testing should be considered at all stages: during development (unit testing), after integration (integration testing), and before release (system and acceptance testing).
健壮的测试计划可以确保系统满足需求且没有严重缺陷。测试应在所有阶段加以考虑:开发期间(单元测试)、集成之后(集成测试)以及发布前(系统测试和验收测试)。
Examples of test cases for the library system include:
该图书馆系统的一些测试用例如下:
| Test Case | Input | Expected Outcome |
|---|---|---|
| Issue a book to a valid member | Member ID 123, Book ID 5 (status available) | Loan record created, book status set to ‘onloan’, due date set to today + 14 days. |
| Return an overdue book | Book ID 5, return date 5 days after due date | Fine of (5 days × £0.10) = £0.50 added to member’s FinesOwed, book status becomes ‘available’. |
| Search for a non-existent title | “Krypton” (no matching book) | Message “No results found” displayed. |
| 测试用例 | 输入 | 预期结果 |
|---|---|---|
| 向有效会员借出图书 | 会员 ID 123,图书 ID 5(状态为可借) | 创建借阅记录,图书状态设为“已借出”,应还日期设为今天 +14 天。 |
| 归还一本逾期图书 | 图书 ID 5,归还日期比应还日期晚 5 天 | 罚款 (5 天 × £0.10) = £0.50 添加至会员的 FinesOwed,图书状态变为“可借”。 |
| 搜索一本不存在的书名 | “Krypton”(无匹配图书) | 显示消息“未找到结果”。 |
Boundary testing is also important: what happens if a member has already borrowed the maximum allowed number of books? Does the system correctly handle a leap-year due date? In your exam, always link test cases back to specific requirements.
边界测试也很重要:如果会员已借满最大允许数量会怎样?系统能否正确处理闰年的应还日期?在考试中,务必将测试用例与具体需求关联起来。
8. Legal, Moral and Ethical Considerations | 法律、道德与伦理考量
The system stores personal data (member names, email, year group) and must therefore comply with the UK Data Protection Act 2018 and GDPR. The school must have a lawful basis for processing this data, and data should be kept secure and not used for purposes other than library management without consent.
该系统存储个人数据(会员姓名、电子邮件、年级),因此必须遵守英国《2018 年数据保护法》及 GDPR。学校必须有处理这些数据的合法依据,且数据必须安全保存,未经同意不得用于图书馆管理以外的目的。
Moral issues include ensuring equitable access: the web portal must be accessible to students with disabilities (e.g. screen-reader compatibility). Ethically, the system should not monitor students’ reading habits for any purpose unrelated to library operation, as this would violate their privacy.
道德问题包括确保平等访问:网页门户必须可供残疾学生访问(例如兼容屏幕阅读器)。从伦理上讲,系统不应监控学生的阅读习惯以用于与图书馆运营无关的任何目的,否则将侵犯其隐私。
The Computer Misuse Act 1990 is also relevant: unauthorised access to the system to alter fines or delete loan records would be a criminal offence. The system must implement authentication and access control, ensuring only librarians can modify data. In your exam, be prepared to discuss such legislation with clear examples from the case study.
《1990 年计算机滥用法案》也同样相关:未经授权访问系统以篡改罚款或删除借阅记录将构成刑事犯罪。系统必须实施身份认证和访问控制,确保只有图书管理员可以修改数据。在考试中,要准备好结合案例中的明确例子来讨论这些立法。
9. Evaluation and Future Enhancements | 评估与未来改进
After the core system is implemented, we evaluate its success against the original requirements. Did the librarian’s workflow improve? How quickly do searches execute? Are fines calculated accurately? User feedback and performance metrics help identify weaknesses.
在核心系统实施之后,我们依据原始需求评估其成功程度。图书管理员的工作流程是否得到改善?搜索执行有多快?罚款计算是否准确?用户反馈和性能指标有助于发现不足之处。
A possible enhancement is a reservation system: if a book is on loan, a member could place a hold, and the next available copy would be assigned automatically. This would require a queue data structure (perhaps implemented as a linked list or a simple array with pointers) associated with each book. Another improvement is integration with a barcode scanner to reduce manual data entry errors.
一个可能的增强功能是预约系统:如果某书已借出,会员可以发起预约,下一本可用的书将自动分配。这将需要为每本书关联一个队列数据结构(或许实现为链表或带指针的简单数组)。另一个改进是与条形码扫描器集成,以减少手动数据录入错误。
Evaluative comments in an exam answer should acknowledge trade-offs. For example, adding a reservation queue increases system complexity and memory usage, but significantly improves user satisfaction. A strong answer weighs such costs against benefits.
考试答案中的评估性意见应当承认各种权衡。例如,增加预约队列会提高系统复杂性和内存占用,但能大幅提升用户满意度。优秀的答案会权衡此类成本与收益。
10. Conclusion and Exam Tips | 结论与考试技巧
This walkthrough demonstrates how to apply OCR Computer Science concepts to a realistic case study. Always begin by understanding the scenario and identifying stakeholders. Then move to concrete requirements, data design, and algorithm selection before considering implementation, testing, and legal aspects.
本次演练展示了如何将 OCR 计算机科学的概念应用于真实的案例研究。始终从理解场景和识别利益相关者开始,然后转向具体需求、数据设计、算法选择,再考虑实施、测试和法律层面。
In the exam, use precise terminology (e.g., “binary search has O(log n) time complexity”) and support your answers with clear pseudocode or diagrams where appropriate. When discussing ethical issues, link each point to a specific scenario detail. Practise writing test plans that directly address the functional requirements, and always keep the mark scheme in mind: structure your response with clear sections and justification.
在考试中,使用精确的术语(例如“二分搜索具有 O(log n) 的时间复杂度”),并在适当时用清晰的伪代码或图表支持你的答案。讨论伦理问题时,将每个要点与具体的场景细节联系起来。练习编写直接针对功能需求的测试计划,并始终牢记评分细则:用清晰的段落和理由构建你的回答。
Published by TutorHao | Computer Science Revision Series | aleveler.com
更多咨询请联系16621398022(同微信)
屏轩国际教育cambridge primary/secondary checkpoint, cat4, ukiset,ukcat,igcse,alevel,PAT,STEP,MAT, ibdp,ap,ssat,sat,sat2课程辅导,国外大学本科硕士研究生博士课程论文辅导