Skip to content

Software Engineering

University Computer Science Topic 12 6:03 English narration · English and 中文 subtitles you can switch

space play · ←/→ 5s · j/l 10s · f fullscreen · c subtitles · ,/. speed

Chapters

Transcript
Software engineering is how systems outlive their authors. 软件工程让系统的寿命超越其作者。
The first three units shape the product: requirements, architecture and interface design. 前三个单元塑造产品:需求、架构和界面设计。
The next two hold the line, with version control and testing. 接下来的两个单元通过版本控制和测试守住质量。
The last two finish it, with security, ethics and a team project. 最后两个单元涉及安全、伦理和团队项目,完成整个过程。
One running project, a book-sharing service called BookShare, supplies every example, and each one is checked. 贯穿始终的项目是一个名为 BookShare 的图书共享服务,所有例子都来自这个项目,并且每个例子都经过检验。
Functional requirements say what the system does: a member may hold at most five loans, and the due date is the borrow date plus 21 days. 功能需求说明系统做什么:一名会员最多可以借阅五本书,到期日是借书日期加 21 天。
Non-functional requirements say how well: search must answer within 2 seconds for 95 per cent of requests. 非功能需求说明系统做得有多好:95% 的搜索请求必须在 2 秒内得到响应。
Easy to use cannot fail a test, but a measured first borrow under three minutes can. “易于使用”无法作为测试失败的判据,但首次借书用时是否少于三分钟,可以通过测量来检验。
This use-case diagram shows the system boundary, the actors outside it and their goals inside it. 这张用例图展示了系统边界、边界外的参与者及边界内他们要实现的目标。
A Member borrows a book. 会员借书。
A Librarian registers new titles. 图书管理员登记新书目。
The System itself sends reminders for overdue loans. 系统本身发送逾期借书提醒。
Agree on this picture in writing early, before any code, or you will disagree about it forever. 要在编写任何代码之前尽早以书面形式就这张图达成一致,否则你们会一直为此争论不休。
The architecture has three layers: presentation for the web pages, a domain layer for the loan rules, and storage for the database. 这个架构有三层:负责网页的表示层、负责借阅规则的领域层,以及负责数据库的存储层。
Dependencies point inward only, so the domain knows nothing about frameworks and is easy to test. 依赖关系只指向内层,因此领域层完全不依赖框架,也易于测试。
Changing a loan rule touches one module and two files; with the rule smeared across layers, it touches five files. 修改一条借阅规则只涉及一个模块和两个文件;如果规则散布在各层,就会涉及五个文件。
Walk the arrows in these two diagrams. 沿着这两张图中的箭头看一遍。
The layer diagram shows dependencies pointing only inward. 分层图显示依赖关系只指向内层。
The sequence diagram shows one borrow: presentation calls the domain's borrow method, the domain checks the limit and the book's status, and storage records the loan with its dates. 时序图展示了一次借书过程:表示层调用领域层的借书方法,领域层检查借阅上限和书籍状态,存储层记录借阅及其日期。
Count the files a change would touch: that count is your coupling. 数一数一次修改会涉及多少个文件:这个数量反映了耦合程度。
An interface is a state machine with manners: browsing, detail, confirm, done and error. 界面就像一个懂礼貌的状态机:浏览、详情、确认、完成和错误。
Every state needs a visible way out, and the error state keeps the user's input. 每个状态都需要一个可见的出口,而错误状态要保留用户输入。
Accessibility must be measurable. 无障碍性必须能够衡量。
Body text at a contrast of 7 to 1 passes; grey text at 2.9 to 1 fails. 正文的对比度达到 7:1 就合格;灰色文字的对比度为 2.9:1 则不合格。
Every action must also work by keyboard alone. 每个操作也必须能够仅用键盘完成。
Trace the five interface states and their transitions. 依次追踪界面的五个状态及其转换。
From browsing you open a book's detail, confirm a borrow, and reach done. 从浏览状态打开一本书的详情,确认借阅,然后进入完成状态。
If something fails, you land in the error state, which always offers a way back to detail with your input kept. 如果出现问题,就会进入错误状态;该状态始终提供返回详情的途径,并保留你的输入。
Every state has at least one exit, so no user is ever trapped. 每个状态至少有一个出口,所以用户不会被困在任何状态。
The main branch must always be releasable, and each commit should be one change you can defend. 主分支必须始终处于可发布状态,每次提交都应当是一项你能说明理由的改动。
Short-lived branches go through reviewed pull requests. 短期分支通过经过审查的拉取请求合并。
Small, runnable commits make bisecting work: twelve commits narrow a regression in at most four checkouts. 小而且可运行的提交使二分查找成为可能:对于十二次提交,最多检出四次就能定位一次回归。
A merge conflict is a decision, so record it in the merge message. 合并冲突需要作出决策,所以要把决策记录在合并信息中。
Review against tests, not taste. 审查要依据测试,而不是个人喜好。
In this branch graph, two features leave main. 在这张分支图中,两个功能分支从 main 分出。
One merges cleanly. 其中一个顺利合并。
The other collides with it on the loan limit: one branch sets it to 6, the other moves it into configuration. 另一个在借阅上限上与它发生冲突:一个分支将上限设为 6,另一个则把它移入配置。
Git cannot decide which is right, because that is a product decision. Git 无法决定哪个正确,因为这是产品决策。
The collision starts a conversation, and its outcome belongs in the merge message. 冲突促成讨论,讨论结果应记录在合并信息中。
Build many fast unit tests, fewer integration tests and only a few end-to-end tests. 编写大量运行快速的单元测试、较少的集成测试,以及少量端到端测试。
Branch coverage is the honest number: 92 per cent of lines but 81 per cent of branches means some decisions were never tested. 分支覆盖率才是更真实的数字:行覆盖率为 92%,分支覆盖率为 81%,说明有些判断从未经过测试。
Push a failing test for the sixth borrow, see red, add the limit, see green, and the merge is unblocked. 提交一个针对第六次借书且会失败的测试,看到红灯后加入上限,再看到绿灯,就可以解除合并阻塞。
Follow the pipeline from a push. 从一次推送开始,跟踪整个流水线。
Continuous integration installs the project, runs the unit tests, then the integration tests, then checks coverage against an 85 per cent gate. 持续集成先安装项目,运行单元测试,再运行集成测试,然后根据 85% 的门槛检查覆盖率。
Any red step blocks the merge; only green merges. 任何一步出现红灯都会阻止合并;只有全部绿灯才能合并。
Tests are the reason anyone dares to change code that other people depend on. 正因为有测试,人们才敢修改其他人依赖的代码。
A threat model lists the assets, such as member records and loan history, the entry points and the attackers, then pairs each threat with a mitigation and a test. 威胁模型列出会员记录和借阅历史等资产、入口点以及攻击者,然后为每项威胁配上缓解措施和测试。
Three roles and six actions make 18 permissions; only 4 are allowed, and everything else is denied by default. 三个角色和六项操作构成 18 项权限;其中只允许 4 项,其余默认全部拒绝。
Selling reading history is refused in writing, with alternatives offered. 以书面形式拒绝出售阅读历史,并提出替代方案。
Put the assets at the centre of the threat model: member records and loan history. 把资产放在威胁模型的中心:会员记录和借阅历史。
Around them are the entry points: the web form, the API and the reminder service. 周围是入口点:网页表单、API 和提醒服务。
Each threat on the sketch is paired with its mitigation, such as parameterised queries against injection. 草图中的每项威胁都配有缓解措施,例如用参数化查询防范注入。
The finished model becomes the checklist for every security review. 完成后的模型会成为每次安全审查的检查清单。
On a team board, each story carries its tests, and done means the pipeline is green and the code is reviewed. 在团队看板上,每个用户故事都附有相应测试,而“完成”意味着流水线显示绿灯且代码已通过审查。
In week four, three stories are in flight, and the reminder story is blocked, visibly, on a missing credential. 第四周有三个故事正在进行,提醒功能的故事因为缺少凭据而被阻塞,这一点清晰可见。
At 8 points a week, 52 remaining points means about six and a half weeks, recalibrated at every retrospective. 按照每周 8 点计算,剩余 52 点意味着还需要大约六个半星期,并在每次回顾会上重新估算。
Read the project board for week four. 看看第四周的项目看板。
Three stories are in progress, and one card is marked blocked, waiting for the notifier configuration. 三个故事正在进行,其中一张卡片标记为阻塞,正在等待通知服务的配置。
Making the block visible is the whole point: the team sees it at once and can pair on it. 将阻塞情况显示出来正是关键:团队能立刻看到,并可以结对解决。
Any blocker older than two days is escalated, so nothing stays stuck quietly. 任何持续超过两天的阻塞都会上报,因此不会有问题悄悄地一直卡着。
Now test yourself from memory. 现在凭记忆自测。
What does FR-2 say the due date is? FR-2 规定的到期日是什么?
How many layers and files does the smeared loan rule touch? 散布各处的借阅规则涉及多少层和多少个文件?
Bisecting over 12 commits, how many checkouts do you need at most? 对 12 次提交进行二分查找,最多需要检出多少次?
How many of the 18 cells in the permission matrix are allowed? 权限矩阵的 18 个单元格中有多少个是允许的?
Pause, answer, then find it on the figure. 暂停,回答,然后在图中找到答案。

Comments

    Log in or create account

    IGCSE, A-Level & AP