📱 Học IELTS miễn phí: App IELTS 6.0
Giới Thiệu
Bạn đang viết requirements cho feature mới. Bạn cần diễn đạt:
“Nếu user nhập sai password 5 lần thì khóa tài khoản.”
Bằng tiếng Anh, bạn viết thế nào? 🤔
✅ "If the user enters an incorrect password 5 times, the account shall be locked."
Câu điều kiện (Conditional Sentences) là xương sống của requirements, specs, test cases, và error handling trong IT. Hầu hết mọi logic nghiệp vụ đều có dạng “Nếu A thì B”. Viết đúng câu điều kiện = specs rõ ràng, ít bug, ít misunderstanding.
Bài này hướng dẫn cách dùng từng loại Conditional phù hợp trong từng ngữ cảnh IT thực tế.
1. Tổng Quan 4 Loại Câu Điều Kiện
| Loại | Cấu trúc | Dùng khi | Ví dụ IT |
|---|---|---|---|
| Type 0 (sự thật) | If + present, present | Quy luật luôn đúng | “If the server crashes, the watchdog restarts it.” |
| Type 1 (có thể xảy ra) | If + present, will/shall + V | Tình huống thực tế có thể xảy ra | “If the user clicks Submit, the form will be validated.” |
| Type 2 (giả định) | If + past, would + V | Tình huống giả định / không chắc | “If we had more budget, we would hire another developer.” |
| Type 3 (quá khứ không xảy ra) | If + past perfect, would have + V3 | Phân tích lỗi đã qua | “If we had added rate limiting, the server wouldn’t have crashed.” |
💡 Trong IT: Type 0 và Type 1 chiếm 90% các câu điều kiện bạn sẽ viết. Type 2 dùng trong discussions, Type 3 dùng trong post-mortems.
2. Type 0 — Sự Thật & System Behavior
Khi nào dùng?
Mô tả hành vi luôn luôn xảy ra — quy tắc hệ thống, logic cố định, default behavior.
Công thức
Ví dụ trong IT
| Câu điều kiện | Ngữ cảnh |
|---|---|
| “If the cache expires, the system fetches data from the database.” | System architecture |
| “When a request times out, the client retries automatically.” | API behavior |
| “If disk usage exceeds 90%, an alert is triggered.” | Monitoring rules |
“When the container starts, environment variables are loaded from .env.” | Docker config |
| “If the JWT token is invalid, the API returns a 401 error.” | Auth logic |
📌 Lưu ý: Với Type 0, “When” và “If” dùng thay thế được vì sự việc luôn xảy ra.
3. Type 1 — Requirements & Specifications
Khi nào dùng?
Viết requirements, user stories, acceptance criteria — những điều kiện có thể xảy ra trong tương lai.
Công thức
💡 “shall” vs “will”: Trong requirements formal (RFC, contract), “shall” = bắt buộc. “will” = dự kiến. Trong specs thông thường, dùng “will” là đủ.
Ví dụ — User Stories & Acceptance Criteria
| |
Ví dụ — Technical Specs
| Requirement | Conditional Sentence |
|---|---|
| Validate input | “If the input contains special characters, the system will reject the request.” |
| Rate limiting | “If a user exceeds 100 requests/minute, the API will return a 429 status.” |
| Auto-scaling | “If CPU usage reaches 80%, a new instance will be provisioned.” |
| Data backup | “If the backup fails, the admin will be notified via email.” |
| Feature flag | “If the feature flag is enabled, the new UI will be displayed.” |
4. Type 2 — Discussions & Proposals
Khi nào dùng?
Thảo luận giả định, đề xuất giải pháp, bàn về options chưa quyết định.
Công thức
Ví dụ trong Meeting & Email
| Tình huống | Câu điều kiện |
|---|---|
| Đề xuất tech stack | “If we used GraphQL, we would reduce the number of API calls.” |
| Bàn về timeline | “If we had two more sprints, we would be able to add full test coverage.” |
| Xin thêm resource | “If we hired a DevOps engineer, deployments would be much smoother.” |
| So sánh options | “If we switched to PostgreSQL, we would get better JSON support.” |
| Risk assessment | “If the database went down, we would lose all real-time data.” |
Email mẫu — Đề xuất giải pháp:
5. Type 3 — Post-Mortems & Retrospectives
Khi nào dùng?
Phân tích sự cố đã xảy ra — incident reports, retrospectives, lessons learned.
Công thức
Ví dụ — Incident Post-Mortem
| |
6. Ngoài “If” — Các Từ Điều Kiện Khác Trong IT
Unless (= If not)
| Unless | Tương đương If not |
|---|---|
| “Unless the token is valid, the request will be rejected.” | “If the token is not valid…” |
| “Unless the user confirms, the data will not be deleted.” | “If the user does not confirm…” |
| “Unless otherwise specified, the default timeout is 30s.” | “If not otherwise specified…” |
Provided that / As long as (miễn là)
In case (trong trường hợp / phòng khi)
7. Bảng Từ Vựng — Conditional Patterns Trong IT
| Cụm từ | IPA | Nghĩa tiếng Việt | Ngữ cảnh |
|---|---|---|---|
| if…then | /ɪf…ðen/ | nếu…thì | Logic, requirements |
| unless | /ʌnˈles/ | trừ khi | Negative conditions |
| provided that | /prəˈvaɪdɪd ðæt/ | miễn là | Formal specs |
| as long as | /æz lɒŋ æz/ | miễn là | Informal specs |
| in case | /ɪn keɪs/ | trong trường hợp | Error handling |
| otherwise | /ˈʌðəwaɪz/ | nếu không thì | Default behavior |
| on condition that | /ɒn kənˈdɪʃən ðæt/ | với điều kiện | Contracts, SLAs |
| shall | /ʃæl/ | sẽ (bắt buộc) | Formal requirements |
| given that | /ˈɡɪvən ðæt/ | cho rằng / với điều kiện | Test scenarios |
| assuming | /əˈsjuːmɪŋ/ | giả sử | Discussions |
| acceptance criteria | /əkˈseptəns kraɪˈtɪəriə/ | tiêu chí chấp nhận | User stories |
| edge case | /edʒ keɪs/ | trường hợp biên | Testing |
| happy path | /ˈhæpi pɑːθ/ | luồng chính (không lỗi) | Test cases |
| fallback | /ˈfɔːlbæk/ | phương án dự phòng | Error handling |
| threshold | /ˈθreʃhəʊld/ | ngưỡng | Monitoring, limits |
8. Viết Test Cases Bằng Câu Điều Kiện
Test cases chính là câu điều kiện! Format Given-When-Then cực kỳ phổ biến:
Given-When-Then (BDD Style)
| |
If-based Test Cases (Traditional)
| |
9. Lỗi Thường Gặp
❌ Lỗi 1: Dùng “will” trong mệnh đề If
📌 Quy tắc: Mệnh đề If không dùng will (trừ khi “will” mang nghĩa “sẵn lòng”).
❌ Lỗi 2: Nhầm Type 1 và Type 2
❌ Lỗi 3: Thiếu “will/shall” trong mệnh đề chính
❌ Lỗi 4: Dùng “unless” rồi phủ định thêm
10. Practice — Bài Tập Thực Hành
Exercise 1: Xác định loại Conditional
Mỗi câu sau thuộc Type mấy?
- “If the build fails, the deployment is automatically cancelled.”
- “If we migrated to Kubernetes, we would have better auto-scaling.”
- “If we had written integration tests, we would have caught the bug earlier.”
- “If the user uploads a file larger than 5MB, the system will show an error.”
📝 Đáp án
- Type 0 — Sự thật / behavior luôn xảy ra (present + present)
- Type 2 — Giả định (past + would)
- Type 3 — Quá khứ không xảy ra (past perfect + would have V3)
- Type 1 — Requirement có thể xảy ra (present + will)
Exercise 2: Viết Requirements bằng Conditional
Chuyển các yêu cầu sau sang câu điều kiện tiếng Anh:
- Nếu user chưa đăng nhập → redirect về trang login
- Nếu password dưới 8 ký tự → hiện lỗi validation
- Nếu server không phản hồi trong 30s → hiện timeout error
- Trừ khi admin approve → user không thể truy cập
- Miễn là API key hợp lệ → request được xử lý
📝 Đáp án
- “If the user is not logged in, the system shall redirect to the login page.”
- “If the password is less than 8 characters, a validation error will be displayed.”
- “If the server does not respond within 30 seconds, a timeout error will be shown.”
- “Unless the admin approves, the user will not be able to access the resource.”
- “As long as the API key is valid, the request will be processed.”
Exercise 3: Viết Post-Mortem
Tình huống: API bị down 2 tiếng vì deploy code chưa test kỹ.
Viết 3 câu Type 3 phân tích nguyên nhân:
📝 Đáp án gợi ý
- “If we had run the full test suite before deploying, we would have caught the breaking change.”
- “If we had used a canary deployment strategy, the impact would have been limited to a small percentage of users.”
- “If we had set up automated rollback, the downtime would have been reduced to minutes instead of hours.”
Tổng Kết
| Loại | Dùng trong IT khi | Ví dụ |
|---|---|---|
| Type 0 | System behavior, monitoring rules | “If the CPU exceeds 90%, an alert is sent.” |
| Type 1 | Requirements, specs, test cases | “If the user clicks Delete, a confirmation dialog will appear.” |
| Type 2 | Proposals, discussions, planning | “If we used microservices, we would scale better.” |
| Type 3 | Post-mortems, retrospectives | “If we had added monitoring, we would have detected it sooner.” |
Mẹo cuối: Hầu hết requirements dùng Type 1 + shall/will. Khi viết specs, hãy nghĩ theo pattern: “If [condition], the system shall [action].” Đơn giản, rõ ràng, không gây hiểu nhầm! 💪
📌 Bài liên quan:
📌 Bookmark bài này để dùng khi viết requirements & specs nhé! Chia sẻ cho team nếu bạn thấy hữu ích. 🚀