Sub topic 1
Why requirements come before design
Prerequisites
This chapter assumes you know how a client talks to a server over a web API. It also assumes you know what a database and a cache do, and that you can read short Python snippets. No earlier chapter is needed.
What requirements are
A requirement is a statement about what a system must do or how well it must do it. Requirements describe the problem. Design describes one possible answer. If you pick the answer before you agree on the problem, you may build something that works but is the wrong thing.
Requirements fall into two groups:
- Functional requirements say what the system does. Example: "Requesting a short URL redirects to the original long URL."
- Non-functional requirements say how well it does it. Example: "99% of redirects complete in under 100 ms."
Later chapters cover each group in detail. Here the goal is to see why both must come first.
Why design cannot start without them
The same feature can lead to very different systems depending on the quality targets attached to it. Consider "users can look up a short URL":
- At 10 requests per second and a few hours of allowed downtime, one server and one database are enough.
- At 7,000 requests per second with a 100 ms latency target, you need caching, several servers, and a plan for failures.
The feature is the same. The architecture is not. Only the requirements tell you which one to build.
What goes wrong without them
Skipping requirements usually fails in one of three ways:
- Over-building. The team adds sharding and multi-region replication for a system that serves a few hundred users.
- Under-building. The team ships a single database, then finds it cannot meet a latency or availability promise already made to customers.
- Building the wrong thing. Two people hold different unstated assumptions, and the mismatch appears only at launch.
Changing a requirement on paper costs minutes. Changing it after the data model and services are built can cost months.
A small example
A requirements document can be short. This one separates what the system does, how well it does it, and what it will not do:
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.
non_functional:
- id: NFR-1
quality: latency
text: 99% of redirects complete in under 100 ms, measured at the service edge over 30 days.
out_of_scope:
- Click analyticsNotice three habits. Each item has an ID so people can refer to it. The non-functional item has a number, a percentile, a measurement point and a time window. The out-of-scope list is explicit, so nobody assumes analytics will be built.
The order of work
A sound sequence is: gather needs from stakeholders, write functional requirements, write measurable non-functional requirements, estimate load, then choose an architecture. You will often loop back. A design may show that a target is too costly, and you then renegotiate it. That loop is normal, but it only works if the starting requirements were written down.
Exercise
A team says, "The app must support photo sharing and be very reliable." Which part is functional, which part is non-functional, and what is missing from the second part?
Show answer
"Support photo sharing" is functional because it names what the system does. "Be very reliable" is non-functional because it describes quality. It is missing a measurable target, for example "photo uploads succeed for 99.9% of requests over a 30-day window."