Skip to content
  • How one clarification answer can change the classes, the outside systems, the failure modes, and the tests of a design, not just a number.
  • How to compare two designs on what they cost, so that the person who decides can choose with the cost in front of them.
  • Which parts of a design an answer does not reach, and why that is a sign the earlier separation worked.
  • When it is worth hiding a choice behind an interface, and when that is speculation.

Q7 asked how many pages each person may print. The prioritization lesson recorded a conflict:

  • Answer A (facilities): “500 pages per person per month.” The report writer’s quota is raised to 2,000 using FR-6.
  • Answer B (a department head): “Our team shares one budget.”

Facilities chose A for launch and asked what B would cost. This page answers that question by building both, so the comparison is between two designs that compile and pass their tests, not between two guesses.

Building both is a teaching device. In practice you would usually sketch the second design (an entity sketch, class outlines, and a list of what changes) rather than build it; the list below is what such a sketch should contain.

“B is the same design with team instead of user in the quota map.”

That reading treats the answer as a renaming. It misses that the service does not know anyone’s team. That information belongs to HR, so B adds an outside system, a new way for a release to fail, a balance shared between people, and a handful of questions nobody has asked yet. The rest of the page finds each of these in the code.

VerifiedCompiled and tested with GNU 11.4.0 and Clang 14.0.0 (C++20, 2026-12-01).

quota.hpp
// Answer A to Q7: every user has their own pages for the month. The
// account keeps the allowance and the pages used, and works out what is
// left from those two numbers whenever it is asked.
class QuotaAccount {
public:
// Throws std::invalid_argument if monthly_pages is negative.
// `explicit`: an int never turns into an account without you asking.
explicit QuotaAccount(int monthly_pages);
// Never negative: 0 if facilities lowered the quota below what was
// already used this month. (It is std::max(0, allowance - used): with
// an allowance of 300 and 400 used, that is 0, not -100.)
[[nodiscard]] int remaining() const;
// Charges the pages if they all fit; otherwise changes nothing. Returns
// true if charged. A negative page count is refused (false), so it can
// never be used to give pages back.
[[nodiscard]] bool try_charge(int pages);
// FR-6. Takes effect at once; pages already used stay used.
// Throws std::invalid_argument if monthly_pages is negative.
void set_monthly_pages(int monthly_pages);
private:
int monthly_pages_; // never negative: the constructor and setter check it
int used_pages_ = 0; // pages charged so far this month
};
// Every user's account. A user without one gets the default (500, Q7) the
// first time it is needed.
class Quotas {
public:
explicit Quotas(int default_monthly_pages);
// Returns the user's account, creating it with the default allowance
// the first time, so it never fails. It returns a reference (&), so the
// caller changes the account stored here, not a copy.
// The reference stays valid while this Quotas lives: std::map never
// moves its elements when others are added.
QuotaAccount& account_for(const UserId& user);
private:
int default_pages_;
// One account per user, looked up by user ID; owned by value.
std::map<UserId, QuotaAccount> accounts_;
};

Each user has a QuotaAccount. Quotas creates one with the default (500) the first time a user needs it, so the service never needs to be told who its users are. set_monthly_pages is FR-6: it is how the report writer gets 2,000. It keeps the pages already used, and remaining() never goes below 0 if facilities lowers a quota under what was already used.

VerifiedCompiled and tested with GNU 11.4.0 and Clang 14.0.0 (C++20, 2026-12-01).

release_station.cpp
// Answer A: release a user's held jobs, oldest first, charging each one to
// that user's own quota. Returns one result per held job; an empty vector
// if the user had nothing held.
std::vector<JobResult> ReleaseStation::release(const UserId& user) {
// The user's own account: nothing outside this service is asked.
// A reference, so try_charge below changes the stored account.
QuotaAccount& quota = quotas_.account_for(user);
std::vector<JobResult> results;
// jobs_for returns a new vector (a temporary). A range-for keeps that
// temporary alive until the loop ends, and because it is a copy,
// held_.remove below cannot pull a job out from under the loop.
for (const PrintJob& job : held_.jobs_for(user)) {
// All of the job's pages or none: a job that does not fit is
// reported, left held, and the loop moves on to the next job.
if (!quota.try_charge(job.pages)) {
results.push_back({job.id, JobOutcome::over_quota});
continue;
}
// Charged: print it here, then stop holding it.
server_.print(printer_, job);
held_.remove(job.id);
results.push_back({job.id, JobOutcome::printed});
}
return results;
}

The release asks nothing outside the service before charging. The only data it needs is the user, which the badge lookup already produced.

Answer A, as an entity sketch: the release station charges the user's own quota account
Text description of the diagram

Six boxes. Dashed “knows 1” arrows go from ReleaseStation to HeldJobs, to Quotas, and to PrintServer, an interface to an outside system: the station holds references to them and owns none. Solid arrows go from HeldJobs to PrintJob, labelled “owns 0..*”, and from Quotas to QuotaAccount, labelled “owns 0..*, one per user”. There is one outside system, the print server.

Diagram source (Mermaid)
flowchart LR
ReleaseStation -.->|knows 1| HeldJobs
ReleaseStation -.->|knows 1| Quotas
ReleaseStation -.->|"knows 1 (outside system)"| PrintServer["PrintServer (interface)"]
HeldJobs -->|"owns 0..*"| PrintJob
Quotas -->|"owns 0..*, one per user"| QuotaAccount

class ReleaseStation

one per printer

Data members

  • PrinterId printer_;
  • HeldJobs& held_; not owned
  • Quotas& quotas_; not owned
  • PrintServer& server_; not owned; the outside system

Member functions

  • std::vector<JobResult> release(const UserId& user);

class Quotas

one account per user

Data members

  • int default_pages_; 500
  • std::map<UserId, QuotaAccount> accounts_;

Member functions

  • explicit Quotas(int default_monthly_pages);
  • QuotaAccount& account_for(const UserId& user); creates one if needed; valid while Quotas lives

class QuotaAccount

one user's pages this month

Data members

  • int monthly_pages_;
  • int used_pages_ = 0;

Member functions

  • explicit QuotaAccount(int monthly_pages); throws if negative
  • int remaining() const; never below 0
  • bool try_charge(int pages);
  • void set_monthly_pages(int monthly_pages); FR-6
Answer A, as a class outline of the parts the answer reaches: one account per user, created with the default on first use
Expected output
Answer A: a quota per person
[2-East] monthly-report.pdf, 1500 pages, for robin
[2-East] slides.pdf, 200 pages, for kim
[2-East] letter.docx, 40 pages, for lee
robin: 500 pages left
kim: 300 pages left
lee: 460 pages left
held jobs: 0

All three jobs print. Robin has 500 of their 2,000 pages left; Kim and Lee each still have their own 500, less what they printed.

B needs to know who is in which team. That is HR’s information, so it arrives through an interface, like the badge system:

VerifiedCompiled and tested with GNU 11.4.0 and Clang 14.0.0 (C++20, 2026-12-01).

budget.hpp
// New with answer B: which team a user is in. That is HR's information, so
// it is another outside system, reached through this interface like the
// badge system.
// `= 0` makes team_of pure virtual: TeamDirectory only says what can be
// asked, and a real HR adapter (or a test fake) derives from it and answers.
class TeamDirectory {
public:
virtual ~TeamDirectory() = default;
// The user's team, or an empty std::optional (std::nullopt) if the
// user is in no team. Not being in a team is an expected answer, so it
// is not an exception.
[[nodiscard]] virtual std::optional<TeamId> team_of(const UserId& user) const = 0;
};

The budget is per team, but facilities still needs to see who prints a lot (goal G3 from the prioritization lesson), so each budget also records usage per person:

VerifiedCompiled and tested with GNU 11.4.0 and Clang 14.0.0 (C++20, 2026-12-01).

budget.hpp
// Answer B to Q7: one team's shared pages for the month. It also records
// who used them, because facilities still needs to see who prints a lot (G3).
class TeamBudget {
public:
// Throws std::invalid_argument if monthly_pages is negative.
explicit TeamBudget(int monthly_pages);
// Never negative: 0 if the budget was lowered below what was used.
// (std::max(0, budget - used): 100 used of a budget lowered to 50 is 0.)
[[nodiscard]] int remaining() const;
// Charges the team if all the pages fit, and records them against the
// user; otherwise changes nothing. Returns true if charged. A negative
// page count is refused. Both totals change together, so the per-user
// numbers always add up to the team's used pages.
[[nodiscard]] bool try_charge(const UserId& user, int pages);
// Pages this user has charged to the team this month; 0 for a user who
// has printed nothing (it does not add them to the map).
[[nodiscard]] int used_by(const UserId& user) const;
// Takes effect at once; pages already used stay used.
// Throws std::invalid_argument if monthly_pages is negative.
void set_monthly_pages(int monthly_pages);
private:
int monthly_pages_;
int used_pages_ = 0; // the whole team's pages this month
std::map<UserId, int> used_by_; // the same pages, split by user (G3)
};
// Every team's budget, set by facilities. There is no default: a team
// without a budget cannot print (assumption B1, to confirm).
class TeamBudgets {
public:
// Creates or changes a team's budget; changing it keeps the pages the
// team has already used. Throws std::invalid_argument if negative.
void set_budget(const TeamId& team, int monthly_pages);
// nullptr if the team has no budget. Non-owning; valid while this
// TeamBudgets lives (std::map never moves its elements).
// A pointer, not a reference, because "no budget" must be possible and
// a reference cannot be empty. The caller must check for nullptr first.
[[nodiscard]] TeamBudget* budget_for(const TeamId& team);
private:
// One budget per team ID. A team appears here only once facilities has
// called set_budget for it.
std::map<TeamId, TeamBudget> budgets_;
};

There is no default budget. A team nobody set up has none, and that raises a question the per-person design never had: what happens to a user with no team, or whose team has no budget? The example takes the cautious answer and records it as an assumption to confirm with facilities:

B1 (to confirm): a user with no team, or whose team has no budget, prints nothing, and their jobs stay held.

VerifiedCompiled and tested with GNU 11.4.0 and Clang 14.0.0 (C++20, 2026-12-01).

release_station.cpp
// Answer B: release a user's held jobs, oldest first, charging each one to
// their team's shared budget. Two lookups come first (team, then budget);
// if either finds nothing, nothing prints. Otherwise the loop is the same
// shape as answer A's, with the team budget in place of a personal quota.
ReleaseResult ReleaseStation::release(const UserId& user) {
// New with answer B: ask another outside system before charging anything.
const std::optional<TeamId> team = teams_.team_of(user);
// `?:` reads "if there is a team, look up its budget, otherwise
// nullptr". *team reads the TeamId out of the optional, which is only
// done when `team` holds one. Either way, budget ends up null when
// there is no team or the team has no budget.
TeamBudget* budget = team ? budgets_.budget_for(*team) : nullptr;
// Assumption B1 (to confirm): no team, or no budget, means nothing prints
// and the jobs stay held.
if (budget == nullptr) return {ReleaseOutcome::no_team_budget, {}};
ReleaseResult result;
// As in answer A: jobs_for returns a copy, kept alive for the whole
// loop, so held_.remove below is safe.
for (const PrintJob& job : held_.jobs_for(user)) {
// The balance is shared: what this user prints, teammates cannot.
// budget-> calls through the pointer, which is known not to be null.
if (!budget->try_charge(user, job.pages)) {
result.jobs.push_back({job.id, JobOutcome::over_team_budget});
continue;
}
server_.print(printer_, job);
held_.remove(job.id);
result.jobs.push_back({job.id, JobOutcome::printed});
}
return result;
}
How this code works: Design B's release
  1. Find the team. team_of returns a std::optional<TeamId>, empty for a user in no team.
  2. Find the budget. The ?: line only calls budget_for when there is a team. budget_for returns a pointer, nullptr when the team has no budget. So budget is nullptr in two cases: no team, or a team with no budget.
  3. Refuse early. If budget is nullptr, the release returns no_team_budget before any job is looked at. Nothing is charged and every job stays held (assumption B1).
  4. The loop. The same as A’s, except that try_charge is called on the shared team budget, through the pointer (budget->), and also records the pages against the user.

A worked example. The demonstration gives the “reports” team 1600 pages, puts Robin and Kim in it, and leaves Lee in no team. Each user badges in once, in this order:

User team_of budget Job, pages try_charge Recorded as
Robin “reports” reports, 1600 left monthly-report.pdf, 1500 true, 100 left printed
Kim “reports” the same budget, 100 left slides.pdf, 200 false (200 > 100) over_team_budget, held
Lee std::nullopt nullptr not looked at not called no_team_budget

Two jobs are left held, Kim’s and Lee’s. Had Kim badged in first, Kim’s slides would have printed and Robin’s report would have been refused: in B, the order matters.

Compare it with A’s release. Three things are new: the call to team_of, the early return with a new outcome, no_team_budget, and the comment about the shared balance. The return type changed from a list of job results to a ReleaseResult with an outcome, because a release can now fail before any job is looked at.

Answer B, as an entity sketch: the release station asks the team directory for the user's team, then charges the team's shared budget
Text description of the diagram

Seven boxes. Dashed “knows 1” arrows go from ReleaseStation to HeldJobs, to TeamBudgets, to PrintServer (an interface to an outside system), and to TeamDirectory, a new interface to a second outside system, HR’s team data. Solid arrows go from HeldJobs to PrintJob, labelled “owns 0..*”, and from TeamBudgets to TeamBudget, labelled “owns 0..*, one per team”. There are two outside systems: the team directory and the print server.

Diagram source (Mermaid)
flowchart LR
ReleaseStation -.->|knows 1| HeldJobs
ReleaseStation -.->|"knows 1 (outside system, new)"| TeamDirectory["TeamDirectory (interface)"]
ReleaseStation -.->|knows 1| TeamBudgets
ReleaseStation -.->|"knows 1 (outside system)"| PrintServer["PrintServer (interface)"]
HeldJobs -->|"owns 0..*"| PrintJob
TeamBudgets -->|"owns 0..*, one per team"| TeamBudget

class ReleaseStation

one per printer

Data members

  • PrinterId printer_;
  • HeldJobs& held_; not owned
  • const TeamDirectory& teams_; not owned; new outside system
  • TeamBudgets& budgets_; not owned
  • PrintServer& server_; not owned

Member functions

  • ReleaseResult release(const UserId& user); can now fail before any job

interface (abstract class) TeamDirectory

HR's data: who is in which team

Member functions

  • virtual std::optional<TeamId> team_of(const UserId& user) const = 0;

class TeamBudgets

one budget per team; no default

Data members

  • std::map<TeamId, TeamBudget> budgets_;

Member functions

  • void set_budget(const TeamId& team, int monthly_pages);
  • TeamBudget* budget_for(const TeamId& team); nullptr if none; non-owning, valid while TeamBudgets lives

class TeamBudget

one team's pages this month, shared

Data members

  • int monthly_pages_;
  • int used_pages_ = 0;
  • std::map<UserId, int> used_by_; per person, for goal G3

Member functions

  • explicit TeamBudget(int monthly_pages); throws if negative
  • int remaining() const;
  • bool try_charge(const UserId& user, int pages);
  • int used_by(const UserId& user) const;
  • void set_monthly_pages(int monthly_pages);
Answer B, as a class outline of the parts the answer reaches: a new outside system, a new outcome, and a budget shared by a team
Expected output
Answer B: one budget per team
[2-East] monthly-report.pdf, 1500 pages, for robin
kim: job 2 not printed: team budget used up
lee: no team budget; nothing printed
team reports: 100 pages left (robin 1500, kim 0)
held jobs: 2

The same three users and jobs, with the team “reports” given 1,600 pages. Robin’s report uses 1,500, so Kim’s 200-page slides no longer fit. Lee is in no team, so nothing prints for Lee. This is the situation facilities described: one person can use up the whole team’s pages. The per-person record shows who did.

Aspect A: per person B: per team
Quota classes QuotaAccount, Quotas TeamBudget (with per-person usage), TeamBudgets
Outside systems Badges, print server Badges, print server, HR’s team directory
New ways to fail None No team; no budget; team directory unavailable (a new F-1, to be handled the same way: fail closed)
Shared mutable state None between users One balance per team: who releases first wins (see the test below)
Setup before anyone prints None (a default for every user) Every team needs a budget, and HR’s data must be right
New questions None B1 (no team); a user who changes team mid-month; a user in two teams; who grants extra pages (FR-5)
Effect on other requirements FR-6 is needed (and built) FR-4’s panel text needs “team budget used up”; FR-5 and FR-6 apply to teams; NFR-4 must save team balances and usage
Tests in the example 5 8

The order dependence in B is visible in a test:

VerifiedCompiled and tested with GNU 11.4.0 and Clang 14.0.0 (C++20, 2026-12-01).

test_variant_b.cpp
// Each test builds a fresh Office (defined above, not shown): robin and kim
// are in team "reports", which has 1600 pages; ana is in "sales", which has
// no budget until a test sets one; lee is in no team. The recording print
// server keeps the ID of every job it was asked to print.
// LLD_TEST(name) defines one test. LLD_CHECK(condition) records a failure
// if the condition is false, LLD_CHECK_EQ(actual, expected) records one if
// the two differ (and prints both), and LLD_CHECK_THROWS(expression, type)
// fails unless the expression throws that type. All come from lld_test.hpp.
// release is [[nodiscard]], so static_cast<void>(...) marks a result the
// test does not need; the tests do the same for job IDs from hold that they
// never use.
// Robin prints a 1500-page report from the shared 1600: allowed, because
// the whole team budget is available to any member. 1600 - 1500 = 100 left.
// budget_for(...)-> is safe here because "reports" always has a budget.
LLD_TEST(the_report_writer_can_use_most_of_the_team_budget) {
Office office;
const int report = office.held.hold("robin", "report.pdf", 1500);
const ReleaseResult result = office.station.release("robin");
LLD_CHECK(result.outcome == ReleaseOutcome::released);
LLD_CHECK(office.server.printed == std::vector<int>{report});
LLD_CHECK_EQ(office.budgets.budget_for("reports")->remaining(), 100);
}
// Kim's 200 pages leave 1400, which is less than robin's 1500, so the
// report is refused and stays held: one job printed, one still held.
LLD_TEST(teammates_share_one_balance_so_whoever_releases_first_wins) {
Office office;
static_cast<void>(office.held.hold("robin", "report.pdf", 1500));
const int slides = office.held.hold("kim", "slides.pdf", 200);
static_cast<void>(office.station.release("kim"));
static_cast<void>(office.station.release("robin"));
// Kim released first, so the report no longer fits.
LLD_CHECK(office.server.printed == std::vector<int>{slides});
LLD_CHECK_EQ(office.held.count(), 1);
}
// Both charge the same budget, yet used_by still tells them apart (G3).
// ana is not in this team and printed nothing, so used_by gives 0.
LLD_TEST(per_person_use_is_still_recorded) {
Office office;
static_cast<void>(office.held.hold("robin", "a.pdf", 300));
static_cast<void>(office.held.hold("kim", "b.pdf", 50));
static_cast<void>(office.station.release("robin"));
static_cast<void>(office.station.release("kim"));
const TeamBudget* reports = office.budgets.budget_for("reports");
LLD_CHECK_EQ(reports->used_by("robin"), 300);
LLD_CHECK_EQ(reports->used_by("kim"), 50);
LLD_CHECK_EQ(reports->used_by("ana"), 0);
}
// Sales gets 100 pages; ana's 80-page flyer leaves 20 for sales, and the
// reports budget is untouched at 1600.
LLD_TEST(another_teams_printing_does_not_use_this_teams_pages) {
Office office;
office.budgets.set_budget("sales", 100);
static_cast<void>(office.held.hold("ana", "flyer.pdf", 80));
static_cast<void>(office.station.release("ana"));
LLD_CHECK_EQ(office.budgets.budget_for("sales")->remaining(), 20);
LLD_CHECK_EQ(office.budgets.budget_for("reports")->remaining(), 1600);
}
// Assumption B1. lee is in no team: team_of gives std::nullopt, so release
// stops before the loop and the job is still held.
LLD_TEST(a_user_in_no_team_prints_nothing_and_keeps_their_jobs) {
Office office;
static_cast<void>(office.held.hold("lee", "letter.docx", 40));
const ReleaseResult result = office.station.release("lee");
LLD_CHECK(result.outcome == ReleaseOutcome::no_team_budget);
LLD_CHECK(office.server.printed.empty());
LLD_CHECK_EQ(office.held.count(), 1);
}
// Assumption B1. ana is in "sales", but in this test sales has no budget,
// so budget_for returns nullptr and nothing prints.
LLD_TEST(a_team_with_no_budget_prints_nothing) {
Office office;
static_cast<void>(office.held.hold("ana", "flyer.pdf", 10));
const ReleaseResult result = office.station.release("ana");
LLD_CHECK(result.outcome == ReleaseOutcome::no_team_budget);
LLD_CHECK(office.server.printed.empty());
}
// 1000 pages used. Raising the budget to 2000 leaves 2000 - 1000 = 1000.
// Lowering it to 500, below what is used, leaves 0, not -500.
LLD_TEST(changing_a_budget_keeps_the_pages_already_used) {
Office office;
static_cast<void>(office.held.hold("robin", "a.pdf", 1000));
static_cast<void>(office.station.release("robin"));
office.budgets.set_budget("reports", 2000);
LLD_CHECK_EQ(office.budgets.budget_for("reports")->remaining(), 1000);
office.budgets.set_budget("reports", 500);
LLD_CHECK_EQ(office.budgets.budget_for("reports")->remaining(), 0);
}
// -1 is refused with std::invalid_argument, and the check happens before
// anything is stored, so the old budget of 1600 is still in place.
LLD_TEST(a_negative_budget_is_rejected) {
Office office;
LLD_CHECK_THROWS(office.budgets.set_budget("reports", -1), std::invalid_argument);
LLD_CHECK_EQ(office.budgets.budget_for("reports")->remaining(), 1600);
}

teammates_share_one_balance_so_whoever_releases_first_wins releases Kim’s slides before Robin’s report, and the report is refused. In A, the order in which two people release never matters. In B it does, so B also needs the concurrency rule from the quality lesson (one lock, or one owning thread, around the charge) to make “first” well defined when two people in one team badge in at the same moment at different printers.

HeldJobs, PrintJob, and PrintServer are the same in both designs, apart from the namespace. So are the badge lookup and expiry, which is why the examples leave them out. The answer to Q7 reached only the quota part and the few lines of the release that call it.

That is not luck. The earlier lessons kept the quota behind its own small classes and kept outside systems behind interfaces. When a requirement is uncertain, keeping it in one place limits how far a different answer can spread. Look for this when you compare designs: how much of each design would a different answer touch?

Should the choice be hidden behind an interface?

Section titled “Should the choice be hidden behind an interface?”

It is tempting to write an interface (say, PageBudget, with try_charge(user, pages)) and give it two implementations, one per answer. Do it only if the program must support both answers at once, for example if some departments share a budget and others do not. Then the interface earns its place.

If only one answer will be used, the interface is speculation: it has one implementation, it fixes a shape before the second answer’s questions (B1, the mid-month team change) have been answered, and B’s real differences (an outside lookup, a new failure outcome) do not fit inside try_charge anyway. Build the design for the answer you have, keep it contained, and change it when the other answer arrives. The principles section returns to this trade-off.

  • Do not build both designs unless the decision is large and the cost is genuinely unclear. A sketch with the comparison table is usually enough.
  • Do not design for every possible answer. Ask the question first. A design that supports per-person, per-team, and per-project budgets, before anyone has asked for the second, is three times the code and tests.
  • Do not let a design choice settle a stakeholder question silently. Choosing B because it is “more flexible” answers Q7 without asking facilities, who own it.

Comparing designs early costs a sketch and an hour. It pays back when the answer is close: the person deciding sees the cost and the new questions, and the design that is built is the one that was chosen. When the answer is clear, the comparison is wasted effort, so do it for the questions whose answers change classes, outside systems, or failure modes, not for the ones that change a constant.

  • Treating an answer as a renaming (“team instead of user”) and missing the new outside system and shared state.
  • Comparing only the happy path. B’s costs are mostly in its failure cases and its new questions.
  • Building an abstraction for both answers when only one is needed.
  • Choosing the more general design by default. Generality is a cost unless someone needs it.
  • Forgetting what the answer does to other requirements, such as FR-5, FR-6, and NFR-4 under B.

Six months after launch with A, facilities decides to adopt team budgets for the finance department only, keeping per-person quotas elsewhere.

Now both answers are needed at once, which is the case where an interface over the two quota designs earns its place. The comparison table already lists what B adds: the team directory, budgets per team, the new failure outcome, and answers to B1 and the other open questions. The new work is the rule for choosing between A and B for each user (by department, from HR), and a test for each side of that rule. HeldJobs and PrintServer still do not change.

Exercise: Predict the design impact of a new answer

Facilities answers a new question, Q23: “A person can belong to more than one team, and chooses which team pays when they release.”

  1. What changes in design A? In design B? Name the classes and functions.
  2. What new questions does the answer raise, and who should answer them?
  3. Which existing tests change, and which new tests would you add?
Show the explained answer

1. Design impact.

  • A: nothing. Teams do not exist in A, so the answer does not reach it. This is worth saying to facilities: the question only matters if they choose B.
  • B: several places.
    • TeamDirectory::team_of returns one optional team; it must return all of the user’s teams (for example, std::vector<TeamId>).
    • ReleaseStation::release needs to know which team the user chose, so it takes a TeamId as well as the user, and must check that the user really is in that team. Otherwise anyone could charge any team, which is a security problem (compare NFR-3).
    • The printer’s panel must offer the choice. That is a new user interaction, so UC-2 gains a step and an alternative flow.
    • TeamBudget’s per-person record is unchanged: usage is still recorded against the user, in whichever team paid.

2. New questions.

  • If the user does not choose (walks away, or the panel times out), which team pays, or does nothing print? (Facilities.)
  • Can different jobs in one release be charged to different teams? (Facilities and the department heads.)
  • Does every printer’s panel support a choice at all? (The printer vendor; this may be a constraint that rules out the answer.)
  • Who may add a person to a second team? (HR.)

3. Tests.

  • Tests that build a FakeTeams with one team per user change to the new team_of return type, and every call to release gains the team.
  • New tests: the chosen team is charged, not the other; a user cannot charge a team they are not in; a user in two teams with no choice made (whatever facilities decides).
  • In A, no test changes.
  • An answer can change much more than a number: B added an outside system, a new failure outcome, shared state, and new questions.
  • Compare designs on classes, outside systems, failure modes, shared state, setup, new questions, and effects on other requirements, and give the comparison to the person who decides.
  • Keeping uncertain requirements in one place limits how far a different answer spreads. Here, Q7 reached only the quota classes and a few lines of the release.
  • Hide a choice behind an interface only when both answers must work at once.