📚 Software Principles and System Design | 软件原理与系统设计
Every software system, from a school database to an air-traffic control system, depends on clear principles and a well-organised design. Without these, even a small program becomes difficult to understand, test, and improve.
从学校数据库到空中交通管制系统,每一个软件系统都依赖于清晰的原理与良好组织的设计。没有这些,即便是小程序也会变得难以理解、测试和改进。
1. Abstraction and Decomposition | 抽象与分解
Abstraction means hiding unnecessary details and showing only the features that matter for a particular task. For example, when using a car, a driver only needs the steering wheel and pedals, not every detail of the engine.
抽象是指隐藏不必要的细节,只展示与特定任务相关的特征。例如,驾驶汽车时,驾驶员只需方向盘和踏板,而不必了解发动机的每个细节。
Decomposition means breaking a large problem into smaller, more manageable sub-problems. Each sub-problem can be solved separately and then combined to solve the whole problem.
分解是指将一个大问题拆分为更小、更易管理的子问题。每个子问题都可以单独解决,再组合起来解决整个问题。
These two ideas are the foundation of computational thinking. They make complex systems easier to design, debug, and communicate to others.
这两个思想是计算思维的基础。它们使复杂系统更容易被设计、调试并与他人沟通。
2. Modularity and Encapsulation | 模块化与封装
A module is a self-contained unit of code with a clear purpose and a defined interface. Modularity is the practice of building a system from such units, allowing independent development and reuse.
模块是具备明确目的和已定义接口的独立代码单元。模块化就是用这样的单元来构建系统,以便独立开发和复用。
Encapsulation is the principle of keeping data and the operations on that data together, while protecting the data from direct external access. In object-oriented programming, this is achieved with private attributes and public methods.
封装是指将数据和对数据的操作放在一起,同时防止外部直接访问数据。在面向对象编程中,这通过私有属性和公有方法来实现。
The benefit of modularity and encapsulation is maintainability. If one module changes, other modules are not affected as long as the interface remains stable.
模块化和封装的好处是可维护性。只要接口保持稳定,一个模块发生改变时,其他模块不会受到影响。
3. Software Development Life Cycle | 软件开发生命周期
The software development life cycle (SDLC) describes the stages of building software: analysis, design, implementation, testing, and maintenance. Different models arrange these stages in different ways.
软件开发生命周期描述构建软件的各阶段:分析、设计、实现、测试和维护。不同的模型以不同方式安排这些阶段。
| Model | 模型 | Key Idea | 核心思想 |
| Waterfall 瀑布模型 | Each phase is completed before the next begins. 每个阶段完成后才开始下一阶段。 |
| Agile 敏捷模型 | Incremental delivery with frequent feedback. 以频繁反馈进行增量交付。 |
| Spiral 螺旋模型 | Repeated risk analysis and prototyping. 反复进行风险分析与原型构建。 |
Waterfall is simple and structured, but it is not flexible when requirements change. Agile is more adaptive, but it requires close cooperation with users and disciplined teams.
瀑布模型简单且结构化,但在需求变化时不够灵活。敏捷更适应变化,但需要与用户密切合作以及纪律性强的团队。
4. Requirements Analysis and Specification | 需求分析与规格说明
Requirements analysis is the process of discovering what the user actually needs. A requirement may be functional, such as "the system must calculate totals", or non-functional, such as "the system must respond within two seconds".
需求分析是发现用户真正需要什么的过程。需求可以是功能性的,例如“系统必须计算总额”,也可以是非功能性的,例如“系统必须在两秒内响应”。
After analysis, the requirements are written into a specification. This specification acts as a contract between the client and the developer, and as a reference for testers.
分析完成后,需求会被写入规格说明。这份规格说明是客户与开发者之间的契约,也是测试人员的参考依据。
Functional requirements describe what the system must do. 功能需求描述系统必须做什么。
Non-functional requirements describe performance, security, usability, and reliability. 非功能需求描述性能、安全、可用性和可靠性。
Poor requirements are one of the most common causes of project failure. Therefore, validation with stakeholders is essential before design begins.
糟糕的需求是项目失败最常见的原因之一。因此,在开始设计之前,必须与利益相关者进行验证。
5. System Architecture and Design | 系统架构与设计
System architecture defines the overall structure: which components exist and how they communicate. A common architecture is layered design, where each layer provides services to the layer above it.
系统架构定义了整体结构:存在哪些组件以及它们如何通信。一种常见架构是分层设计,其中每一层为其上层提供服务。
Data flow diagrams show how data moves through a system. They use circles for processes, rectangles for external entities, and open-ended boxes for data stores.
数据流图显示数据如何在系统中流动。它们用圆圈表示处理过程,用矩形表示外部实体,用开口矩形表示数据存储。
Structure charts show the hierarchy of modules and the calls between them. They help designers check that the decomposition is complete and consistent.
结构图显示模块的层次结构和它们之间的调用关系。它们帮助设计者检查分解是否完整且一致。
Unified Modelling Language (UML) provides standard diagrams such as use-case diagrams, class diagrams, and sequence diagrams. These diagrams improve communication between designers and programmers.
统一建模语言(UML)提供了标准图形,例如用例图、类图和时序图。这些图形改善了设计者与程序员之间的沟通。
6. Implementation and Programming Practice | 实现与编程实践
Implementation is the process of turning a design into executable code. Good programming practice includes meaningful identifiers, consistent indentation, and clear comments.
实现是把设计转换为可执行代码的过程。良好的编程实践包括有意义的标识符、一致的缩进和清晰的注释。
Structured programming uses selection, iteration, and sequence, avoiding unstructured jumps such as GOTO. This makes control flow easier to follow.
结构化编程使用选择、循环和顺序,避免使用 GOTO 等非结构化跳转。这使控制流更容易理解。
In object-oriented programming, the key principles are inheritance, polymorphism, abstraction, and encapsulation. Inheritance allows a class to reuse fields and methods from a parent class.
在面向对象编程中,关键原则是继承、多态、抽象和封装。继承允许类复用父类的字段和方法。
Polymorphism allows the same method call to behave differently depending on the object. This promotes flexibility and reduces duplicated code.
多态允许同一方法调用根据对象不同而表现不同。这提高了灵活性并减少重复代码。
7. Testing Strategies | 测试策略
Testing aims to find errors and to give confidence that the system meets its specification. It is not proof that a program is correct, but it reduces the risk of failure.
测试旨在发现错误,并让系统满足规格说明。它不能证明程序正确,但能降低失败风险。
A useful test plan includes input data, expected output, and the reason for the test. Test data can be normal, boundary, or invalid.
实用的测试计划包含输入数据、预期输出以及测试理由。测试数据可以是正常数据、边界数据或非法数据。
Unit testing tests a single module or function. 单元测试测试单个模块或函数。
Integration testing tests the interfaces between modules. 集成测试测试模块之间的接口。
System testing tests the whole system against the requirements. 系统测试根据需求测试整个系统。
Acceptance testing checks whether the client accepts the system. 验收测试检查客户是否接受该系统。
Black-box testing is based on specifications, while white-box testing is based on the internal structure of the code. Both approaches are valuable and should be used together.
黑盒测试基于规格说明,白盒测试基于代码的内部结构。两种方法都很有价值,应当结合使用。
8. Maintenance and Documentation | 维护与文档
Maintenance is the longest and often most expensive phase of the life cycle. Corrective maintenance fixes errors, adaptive maintenance adjusts to new environments, and perfective maintenance improves performance or usability.
维护是生命周期中最长、往往也最昂贵的阶段。纠错性维护修复错误,适应性维护调整以适应新环境,完善性维护改进性能或可用性。
Documentation is essential for maintenance. User documentation explains how to operate the software, while technical documentation explains the architecture, algorithms, and data structures.
文档对维护至关重要。用户文档解释如何操作软件,技术文档解释架构、算法和数据结构。
Good documentation should be written during development, not after completion. It should be accurate, concise, and kept up to date whenever the code changes.
好的文档应在开发过程中编写,而不是完成后补写。它应当准确、简洁,并在代码变更时及时更新。
9. Operating Systems and Resource Management | 操作系统与资源管理
An operating system is a system software that manages hardware resources and provides a user interface. It controls processors, memory, storage, and input/output devices.
操作系统是一种管理系统硬件资源并提供用户界面的系统软件。它控制处理器、内存、存储和输入/输出设备。
Process management is a central task. A process moves through states such as ready, running, and blocked, and the scheduler decides which process uses the CPU next.
进程管理是核心任务。进程会经过就绪、运行和阻塞等状态,调度器决定下一个使用 CPU 的进程。
Memory management allocates memory to processes and protects one process from accessing another process's memory. Techniques include paging and segmentation.
内存管理为进程分配内存,并防止一个进程访问另一个进程的内存。常用技术包括分页和分段。
Interrupts allow the operating system to respond to external events immediately. When an interrupt occurs, the current process is paused and an interrupt handler runs.
中断使操作系统能够立即响应外部事件。当中断发生时,当前进程被暂停,中断处理程序运行。
10. Evaluation and Security | 系统评估与安全
After a system is built, it must be evaluated against criteria such as efficiency, portability, usability, and maintainability. Evaluation helps decide whether the system is fit for purpose.
系统构建完成后,必须根据效率、可移植性、可用性和可维护性等标准进行评估。评估有助于判断系统是否适合其用途。
Security must be considered throughout design, not added at the end. Principles include least privilege, defence in depth, and secure default settings.
安全必须在整个设计过程中考虑,而不是在最后添加。原则包括最小权限、纵深防御和安全默认设置。
Common threats include malware, denial-of-service attacks, and SQL injection. Validation, encryption, and access control can reduce these risks.
常见威胁包括恶意软件、拒绝服务攻击和 SQL 注入。验证、加密和访问控制可以降低这些风险。
A secure system does not rely only on technology; it also needs clear policies, staff training, and regular security testing.
安全系统不只依赖技术;它还需要明确策略、员工培训和定期的安全测试。
11. Conclusion | 总结
Software principles and system design are not optional extras; they are essential for building reliable, maintainable, and secure systems. Abstraction, modularity, structured development, and thorough testing all work together to manage complexity.
软件原理与系统设计不是可选附加项,而是构建可靠、可维护和安全系统的必要条件。抽象、模块化、结构化开发和彻底测试共同应对复杂性。
By understanding the life cycle, architecture, and operating system foundations, a computer science student can move beyond writing small programs and begin designing real software systems.
通过理解生命周期、架构和操作系统基础,计算机科学学生能够超越编写小程序,开始设计真正的软件系统。
Published by TutorHao | Computer Science Revision Series | aleveler.com
更多咨询请联系16621398022(同微信)

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