Requirements
แนะนำใหม่
6:03
วิศวกรรมซอฟต์แวร์
Software engineering is how systems outlive their authors. The first three units shape the product: requirements, architecture and interface design. The next…
บรรยายภาษาอังกฤษ · สลับคำบรรยายภาษาอังกฤษและภาษาจีนได้
ในบทเรียนนี้
| English | ความหมาย |
|---|---|
| Requirements engineering/rɪˈkwaɪəmənts ˌendʒɪˈnɪərɪŋ/ | finding out, writing down and checking what a system must do |
| functional requirement/ˈfʌŋkʃənl rɪˈkwaɪəmənt/ | ความต้องการด้านฟังก์ชัน |
| non-functional requirement/nɒn ˈfʌŋkʃənl rɪˈkwaɪəmənt/ | ความต้องการที่ไม่ใช่ฟังก์ชัน |
| use case/juːs keɪs/ | กรณีการใช้งาน |
| acceptance test/əkˈseptəns test/ | A test that checks whether a system meets the user's agreed requirements. |
| Availability/əˌveɪləˈbɪlɪti/ | Whether a resource can be obtained when and where it is needed. |
| acceptance criterion/əkˈseptəns kraɪˈtɪərɪən/ | a condition, often written Given-When-Then, that a feature must meet to count as done, checkable by a test |
| percentile/pəˈsentaɪl/ | A value marking a specified percentage of observations at or below it in an ordered distribution. |
What and how well
- Requirements engineering 需求工程 has two kinds of requirement. A functional requirement 功能需求 says what the system does ("a member can borrow up to 5 books"); a non-functional requirement 非功能需求 says how well ("search answers within 2 s").
- A use case 用例 walks through one goal from start to end, with its actors.

Search answers within 2 seconds is —
ความยาก 1/5 · 100 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
It constrains how well the searching works, not what exists.
Testable wording
- "Easy to use" can never fail a test. "A new member completes a first borrow in under 3 minutes without help (measured with 5 first-time users)" can pass or fail.
- The course list. Each requirement maps by name to an acceptance test 验收测试 that can pass or fail:
| ID | Requirement | Test |
|---|---|---|
| FR-1 | at most 5 loans | the sixth borrow is refused |
| FR-2 | due = borrow date + 21 days | borrow 1 March: due 22 March |
| FR-3 | one reminder per overdue day | 3 days late: 3 reminders |
| NFR‑1 | fast search, 10 000 titles | 95% of searches under 2 s |
A requirement is testable when —
ความยาก 1/5 · 100 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
Observable outcome = a verdict exists: pass or fail.
"Search must be fast" is a testable non-functional requirement.
ความยาก 1/5 · 100 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
"Fast" has no number, so no test can fail it. "Search returns in under $2$ s at the 95th percentile on $10\,000$ titles" can.
The trace to code
- Requirement $\to$ acceptance test $\to$ failing test $\to$ the reason for the next commit. This chain can be audited: a commit that closes FR-2 says so.
- Watch for the common mistakes: a solution inside a requirement ("use Redis" names the means, not the need); adjectives that cannot be measured; hidden assumptions (the 21-day period is a named constant, not something people just know).
A commit that closes FR-2 must say so because —
ความยาก 1/5 · 100 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
The auditable chain is what makes the history trustworthy.
Numbers in non-functional requirements
- Non-functional requirements need numbers, and the numbers have costs. Availability 可用性 of $99.9\%$ allows $8\,760 \times 0.001 = 8.76$ hours of downtime a year; $99.99\%$ allows only $53$ minutes, and each extra nine usually means extra servers and staff on call.
- Prioritise before building: MoSCoW sorts requirements into must, should, could and won't (this time). A change, such as cutting the loan period from $21$ to $14$ days, is then traced through its row in the matrix: one named constant, one acceptance test, nothing else.
A service promises 99.95% availability. How many hours of downtime does that allow per year (8760 hours)?
ความยาก 2/5 · 140 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
8760 x 0.0005 = 4.38 hours.
Which is a non-functional requirement?
ความยาก 1/5 · 100 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
It says how well the system performs, with a measurable number.
Given, when, then
- An acceptance criterion 验收标准 in Given–When–Then form is a test written before any code: Given a member holding 5 loans, when they borrow another copy, then the system refuses and shows the limit.
- Each part fixes one thing: the starting state, the action and the result you can observe. "The system handles limits sensibly" fixes none of them.
Which is a testable acceptance criterion?
ความยาก 1/5 · 100 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
It fixes the state, the action and the observable result; the last one is a solution, not a need.
Worked example: why percentiles, not means
- Ten search times in ms: 120, 150, 180, 200, 220, 250, 300, 400, 900, 2500. The mean is $5220/10 = \mathbf{522}$ ms, which looks fine, yet one member waited 2.5 s.
- The 90th percentile 百分位数 by nearest rank is the $\lceil 0.9 \times 10 \rceil = 9$th value, 900 ms. A requirement such as "p95 under 2 s" says how many users may wait, and for how long; a mean says neither.
Search times 120, 150, 180, 200, 220, 250, 300, 400, 900, 2500 ms: mean (ms)?
ความยาก 2/5 · 140 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
$5220/10 = 522$.
Same ten times: 90th percentile by nearest rank (ms)?
ความยาก 2/5 · 140 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
เลข $\lceil 0.9 \times 10 \rceil = 9$th sorted value.
Worked example: rewrite three weak requirements
- Each draft below fails in its own way. Rewrite it so a test can pass or fail.
| Weak draft | Testable rewrite |
|---|---|
| "Search should be fast." (an adjective) | 95% of searches over 10 000 titles return in under 2 s |
| "Use Redis to cache searches." (a solution) | a repeated search returns in under 200 ms |
| "Members must not keep books too long." (vague) | a book borrowed on 1 March shows a due date of 22 March |
- Each rewrite names a number or an observable result, and none of them says how to build it.
Which is the best rewrite of "The system should be reliable"?
ความยาก 1/5 · 100 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
It gives a number and a way to measure it, so it can pass or fail. "Two servers" names a solution, not the need.
Marks that slip away
- The solution inside the requirement. "Use Redis" is a means; state the need, such as search under $2$ s.
- Adjectives instead of numbers. "Fast" and "easy" cannot fail a test.
- Hidden assumptions. Write the 21-day loan period down, or two teams will assume different ones.
Recap
- Functional: what the system does; non-functional: how well, with a number.
- Testable wording can pass or fail: "under 3 minutes for 5 first-time users".
- Requirement → acceptance test → commit: the trace can be audited.
เกิดปัญหาอะไรขึ้น? เฉพาะทีมเว็บไซต์เท่านั้นที่เห็นข้อมูลนี้