LeadershipTechnical ManagerExecution and Process

Session 07 - Requirements Engineering

"Sai requirement tốn gấp 100 lần so với sai code. Fix bug rẻ, fix sai yêu cầu thì cực đắt." - Barry Boehm


1. Requirement Types

1.1 Functional Requirements (FR)

Mô tả hệ thống phải làm gì - hành vi, chức năng cụ thể.

Ví dụ cho E-commerce:

  • Người dùng có thể đăng ký bằng email hoặc Google OAuth
  • Hệ thống gửi email xác nhận đơn hàng trong vòng 30 giây
  • Admin có thể export report dạng Excel và PDF

1.2 Non-Functional Requirements (NFR)

Mô tả hệ thống phải hoạt động như thế nào - quality attributes.

CategoryRequirementMeasurable Target
PerformanceResponse time APIP95 < 200ms
ScalabilityConcurrent users10,000 concurrent users
AvailabilityUptime SLA99.9% (8.76h downtime/year)
SecurityAuthenticationOAuth 2.0 + MFA cho admin
MaintainabilityCode coverage> 80% unit test coverage
UsabilityPage loadFirst Contentful Paint < 1.5s

Thực chiến: NFR thường bị bỏ quên cho đến khi production gặp sự cố. Senior dev phải chủ động hỏi NFR ngay từ đầu dự án.

1.3 Constraints

Giới hạn không thể thương lượng:

  • Technical: Phải dùng .NET 8, SQL Server, Azure
  • Business: Go-live trước 01/06/2025
  • Legal: Tuân thủ GDPR, PCI DSS cho payment
  • Organizational: Team chỉ có 5 developers, budget $200k

2. User Stories Format

Template chuẩn

As a [role/persona]
I want [goal/desire]
So that [benefit/value]

Ví dụ thực tế

Story tốt:

As a online shopper
I want to save items to my wishlist
So that I can purchase them later without searching again

Story tệ:

As a user
I want a wishlist feature
So that the system has wishlist

Tại sao tệ? "User" quá generic, "feature" không mô tả hành vi, "so that" không nêu value thực sự.

INVEST Criteria cho User Stories

Tiêu chíMô tảKiểm tra
IndependentKhông phụ thuộc story khác để deliver valueCó thể deploy riêng?
NegotiableCó thể thảo luận, điều chỉnh scopePO và dev đã thống nhất?
ValuableMang lại giá trị cho user hoặc businessUser care không?
EstimableTeam có thể estimate effortCó đủ thông tin?
SmallĐủ nhỏ để hoàn thành trong 1 Sprint< 8 story points?
TestableCó thể viết test case kiểm chứngAC rõ ràng chưa?

3. Acceptance Criteria - Given-When-Then

Format

gherkin
Given [precondition / initial state]
When [action performed]
Then [expected outcome]

Ví dụ: Login Feature

gherkin
Scenario: Đăng nhập thành công với email hợp lệ
  Given người dùng đã có tài khoản với email "user@example.com"
  And người dùng ở trang Login
  When người dùng nhập email "user@example.com" và password đúng
  And nhấn nút "Đăng nhập"
  Then hệ thống chuyển hướng đến Dashboard
  And hiển thị message "Chào mừng bạn quay lại"

Scenario: Đăng nhập thất bại sau 5 lần sai password
  Given người dùng đã nhập sai password 4 lần
  When người dùng nhập sai password lần thứ 5
  Then tài khoản bị lock trong 30 phút
  And hệ thống gửi email cảnh báo đến người dùng
  And hiển thị message "Tài khoản đã bị khoá tạm thời"

Quy tắc viết AC tốt

  1. Mỗi scenario test 1 behavior - không gộp nhiều case
  2. Dùng data cụ thể - "5 lần" thay vì "nhiều lần"
  3. Cover cả happy path và edge case - đặc biệt error cases
  4. Có thể automation - viết AC kiểu này dễ convert sang SpecFlow/xUnit

4. Requirements Traceability Matrix (RTM)

Mục đích

Theo dõi mỗi requirement từ gốc (business need) đến ngọn (test case, code).

Req IDBusiness NeedUser StoryDesign DocTest CaseStatus
REQ-001Tăng conversion rate checkoutUS-012: One-click checkoutDD-005TC-045, TC-046Implemented
REQ-002Giảm fraud loss 30%US-018: 3DS verificationDD-008TC-052, TC-053In Progress
REQ-003Comply GDPR Article 17US-025: Delete account dataDD-012TC-070Not Started
REQ-004Reduce support tickets 20%US-030: Self-service FAQDD-015TC-078Implemented

Khi nào cần RTM?

  • Bắt buộc: Regulated industries (banking, healthcare, government)
  • Nên có: Dự án > 6 tháng, nhiều team
  • Có thể skip: Startup, small team, rapid prototyping

5. MoSCoW Prioritization

Framework

PriorityÝ nghĩaGuideline
Must haveKhông có thì hệ thống vô dụng~60% total effort
Should haveQuan trọng nhưng có workaround~20% total effort
Could haveNice-to-have, thêm giá trị~20% total effort
Won't haveKhông làm trong release nàyDocumented cho sau

Ví dụ: E-commerce MVP

FeaturePriorityLý do
User registration & loginMustKhông login = không mua được
Product catalog & searchMustCore value proposition
Shopping cart & checkoutMustRevenue-generating flow
Payment integration (VNPay)MustPhải có để thu tiền
WishlistShouldTăng conversion nhưng có thể dùng bookmark
Product reviews & ratingsShouldSocial proof quan trọng
Recommendation engineCouldTăng AOV nhưng phức tạp
Live chat supportCouldNice-to-have, dùng email trước
Multi-languageWon'tV1 chỉ tiếng Việt

Tip: Khi stakeholder nói "tất cả đều Must have" - hỏi lại: "Nếu chỉ được ship 3 features, bạn chọn cái nào?" Buộc họ prioritize.


6. Requirement Review Checklist

Trước khi đưa vào Sprint Backlog

  • Complete: Đủ thông tin để dev bắt tay làm (DoR passed)
  • Consistent: Không mâu thuẫn với requirements khác
  • Unambiguous: Chỉ có 1 cách hiểu duy nhất
  • Testable: Có acceptance criteria rõ ràng, measurable
  • Feasible: Có thể implement với tech stack và timeline hiện tại
  • Traceable: Có thể trace ngược về business need
  • Prioritized: MoSCoW hoặc Weighted Shortest Job First (WSJF)
  • Estimated: Team đã estimate story point
  • NFR considered: Performance, security, scalability đã xét
  • Dependencies identified: Biết phụ thuộc gì, ai, khi nào

Review Process

PO viết Story + AC
    → Dev review (technical feasibility)
    → QA review (testability)
    → UX review (usability)
    → Refinement session (team consensus)
    → Definition of Ready ✅

7. Common Mistakes in Requirements Gathering

Mistake 1: Gold Plating

Vấn đề: Dev tự thêm feature "vì nghĩ user cần". Fix: Chỉ build đúng requirement, đề xuất improvement qua backlog.

Mistake 2: Vague NFR

Vấn đề: "Hệ thống phải nhanh" - nhanh là bao nhiêu? Fix: Luôn có con số: "API response P95 < 200ms với 1000 concurrent users".

Mistake 3: Solution trong Requirement

Vấn đề: "Dùng Redis cache cho product catalog" - đây là solution, không phải requirement. Fix: "Product catalog phải load trong < 500ms" - để dev chọn solution.

Mistake 4: Missing Edge Cases

Vấn đề: Chỉ mô tả happy path. Fix: Luôn hỏi: "Điều gì xảy ra khi...?" - network error, invalid data, concurrent update, timeout.

Mistake 5: Assumption không document

Vấn đề: "Ai cũng hiểu mà" - nhưng mỗi người hiểu khác nhau. Fix: Ghi rõ assumptions trong story. Ví dụ: "Assumption: User đã verify email trước khi checkout".

Mistake 6: Bỏ qua stakeholder quan trọng

Vấn đề: Chỉ hỏi PO, quên operations team, support team, compliance. Fix: Stakeholder mapping - ai bị ảnh hưởng bởi feature này?


Session tiếp theo: Session 08 - Change Management sẽ đi sâu vào quy trình quản lý thay đổi trong dự án phần mềm.