Sub topic 2
Functional requirements: what the system does
This chapter assumes you know how client-server applications and web APIs work, and that you can read short YAML and Python snippets. It covers functional requirements. Quality targets such as latency and availability come in later chapters.
What a functional requirement is
A functional requirement states a behavior the system must perform. It describes an observable input, action and result. If you can write a test that checks "given this input, the system produces this output", the requirement is functional.
Good functional requirements share four traits:
- They name an actor, such as a user, an admin or another service.
- They use one verb for one behavior.
- They describe outcomes, not implementation. "A user can delete a short URL" is a requirement. "Use a DELETE endpoint backed by PostgreSQL" is a design decision.
- They have a stable ID, so tests, designs and tickets can refer to them.
Example
The URL shortener from the topic plan has three functional requirements:
service: url-shortener
functional:
- id: FR-1
text: A user can submit a long URL and receive a short URL.
- id: FR-2
text: Requesting a short URL redirects to the original long URL.
- id: FR-3
text: A user can delete a short URL they created.Each entry describes one behavior. None says how fast, how available or how durable the behavior must be. Those belong in the non-functional list.
Where functional requirements come from
Functional requirements come from the actors who use the system and from the use cases they carry out. Each use case usually yields one or more requirements. The diagram shows the flow.
Common problems
Vague or mixed requirements are hard to build and hard to test. Watch for these patterns:
| Problem | Weak version | Better version |
|---|---|---|
| Vague verb | The system handles URLs. | A user can submit a long URL and receive a short URL. |
| Two behaviors in one | Users can create and delete links. | Split into FR-1 and FR-3. |
| Design disguised as requirement | Store links in Redis. | Requesting a short URL redirects to the original. |
| Missing actor | Links can be deleted. | A user can delete a short URL they created. |
The last row matters most. "They created" is a rule about who may act. Without it, anyone could delete any link, and testers would not know to check.
Checking a requirement
Before you accept a requirement, ask three questions:
- Can I name the actor?
- Can I write a test with a clear pass or fail?
- Does the text avoid saying how to build it?
If any answer is no, rewrite the requirement before moving on.
Exercise
Classify each statement as functional, non-functional or a design decision: (a) "A user can delete a short URL they created." (b) "99% of redirects finish in under 100 ms." (c) "Use a hash function to generate short codes."
Show answer
(a) is functional: it states an actor and a testable behavior. (b) is non-functional: it states how well the system performs. (c) is a design decision: it dictates how to build the system rather than what it must do.