Objects, responsibilities, and collaborations
What you will learn on this page
Section titled “What you will learn on this page”- The difference between a class and an object.
- How to describe an object by its responsibilities: what it knows, and what it does.
- How to find responsibilities by starting from behaviour, not from a list of nouns.
- How to record a design on CRC cards, and how objects collaborate.
Classes and objects
Section titled “Classes and objects”A class is a description: MemberAccount says what every member account
knows and can do. An object is one actual thing described by that class:
Ada’s account, which allows one loan at a time, and Alan’s, which allows three.
A program has a few classes and, while it runs, possibly thousands of objects.
When designing, it helps to think about objects first: “when Ada asks to borrow this copy, which thing answers, and what does it need to know?” Classes are what you write down afterwards, so that every object of the same kind behaves the same way.
Start from behaviour
Section titled “Start from behaviour”A tempting way to start is to underline every noun in the problem statement and make each one a class. It produces classes, but not a design: it says nothing about what each class is for, and it creates classes for things the software never needs to remember.
Start instead from something the system must do. Here is one piece of library behaviour:
A member borrows a copy of a book at the loan desk. The loan is refused if the library does not own that copy, if the copy is already out, or if the member may not borrow more: either they already hold as many items as their limit allows, or their account is blocked. A loan lasts 21 days. When the copy comes back, it is available again.
Then ask which questions must be answered, and which actions must happen, for that behaviour to work:
- Does the library own copy C-1?
- Is C-1 on the shelf?
- How many items does this member hold now?
- May this member hold one more?
- Record the loan, with its due day.
- Mark C-1 as no longer on the shelf.
- On return: close the loan, and put C-1 back.
Each question is a knowing responsibility: some object must have, or be able to work out, that information. Each action is a doing responsibility: some object must carry it out. A responsibility is a reason for an object to exist.
Give each responsibility to the object that knows
Section titled “Give each responsibility to the object that knows”A useful rule for placing a responsibility: give it to the object that already has the information needed to carry it out. (This rule is often called information expert.) That keeps data and the code that uses it together, so a change to the data changes one class.
- Questions 1, 2, and 6, and the “put C-1 back” half of 7, are about copies, so they belong to whatever knows the library’s copies: a catalog.
- Question 4 depends on the member’s limit and whether the account is blocked: facts about the member, so a member account answers it, given the number from question 3.
- Questions 3 and 5, and the “close the loan” half of 7, are about loans, which connect a copy to a member and a due day. They belong to a loan ledger: the record of who has what.
- Someone has to ask these questions in the right order and decide the result. That is a loan desk: a coordinator that knows nothing about copies, members, or loans itself, and asks the others.
Some nouns from the problem statement did not become classes, each for a reason:
- Book. Only copies are lent, and the only fact needed about a book is its
title, which each copy can store. A
Bookclass would be needed once the library must, for example, find any free copy of a title. - Shelf. “On the shelf” is one
boolper copy. Nothing here needs to know which shelf. - Library. The whole program is the library. A
Libraryclass holding everything would be a container for the other classes, with no responsibility of its own. - Due date. A plain day number is enough for this lesson. A real system would use a date type, a value object of the kind the next lesson describes.
CRC cards
Section titled “CRC cards”A CRC card records one class on one index card (or one box in a document): its Class name, its Responsibilities, and its Collaborators, the other classes it works with to carry them out. The cards are cheap to write, rewrite, and throw away, which is the point: they let you try a design out before writing code. A common way to test them is to walk through a scenario aloud, pointing at each card as it acts.
| Class | Responsibilities | Collaborators |
|---|---|---|
Catalog |
Knows every copy the library owns, and whether each is on the shelf. Records a copy leaving and returning. | none |
MemberAccount |
Knows the member’s ID, loan limit, and whether the account is blocked. Answers “may this member hold n items?” | none |
LoanLedger |
Knows every open loan: which copy, which member, which due day. Opens and closes loans; counts a member’s loans. | none |
LoanDesk |
Carries out a checkout or a return, in the right order, and reports the result. Knows the loan period. | Catalog, MemberAccount, LoanLedger |
Notice the shape. Three cards know things and have no collaborators. One card coordinates and knows almost nothing. Each card’s responsibilities fit in a sentence or two, and they belong together: that is high cohesion.
From cards to code
Section titled “From cards to code”Each card becomes a class whose header comment repeats the card: what it knows, and what it does.
VerifiedCompiled and tested with GNU 11.4.0 and Clang 14.0.0 (C++20, 2026-12-01).
// One physical copy of a book: its title, and whether it is on the shelf// right now. A plain struct, because the Catalog is the only class that// changes it. A new copy starts on the shelf.struct Copy { std::string title; bool on_shelf = true;};
// Knows: every copy, by copy ID, and whether it is on the shelf.// Does: adds copies, and records a copy leaving or returning to the shelf.class Catalog {public: // Returns false, changing nothing, if copy_id is already in use. // Otherwise stores a new Copy, on the shelf, and returns true. bool add(std::string copy_id, std::string title);
// False for a copy the library does not own, as well as for one that // is out: an unknown copy is not on the shelf either. [[nodiscard]] bool is_on_shelf(const std::string& copy_id) const; // True if a copy with this ID was ever added. [[nodiscard]] bool owns(const std::string& copy_id) const;
// Precondition: owns(copy_id). Throws std::out_of_range otherwise. // Each one sets on_shelf (false when lent, true when returned). They do // not check the old value: knowing whether a copy may be lent is the // LoanDesk's job, not the catalog's. void mark_lent(const std::string& copy_id); void mark_returned(const std::string& copy_id);
private: // Copies looked up by copy ID ("C-1" -> {"Dune", true}). A std::map // keeps each key once, so two copies can never share an ID. std::less<> // makes the comparison "transparent": a lookup could pass another // string type, such as std::string_view, without building a std::string. std::map<std::string, Copy, std::less<>> copies_;};VerifiedCompiled and tested with GNU 11.4.0 and Clang 14.0.0 (C++20, 2026-12-01).
// Knows: who the member is, how many items they may borrow at once, and// whether the account is blocked (for example, for unpaid fines).// Does: answers "may this member hold N items at once?"; blocks and unblocks.class MemberAccount {public: // loan_limit is the most items the member may hold at the same time. // A new account starts unblocked. The constructor does not check its // arguments. MemberAccount(std::string member_id, int loan_limit);
[[nodiscard]] const std::string& id() const noexcept { return member_id_; } // True if the member is not blocked and loans_held is within the limit. // The caller says how many items the member would hold; the account // does not know about loans (see may_hold in member_account.cpp). [[nodiscard]] bool may_hold(int loans_held) const noexcept;
// noexcept: setting a bool cannot fail. void block() noexcept { blocked_ = true; } void unblock() noexcept { blocked_ = false; }
private: std::string member_id_; int loan_limit_; bool blocked_ = false;};VerifiedCompiled and tested with GNU 11.4.0 and Clang 14.0.0 (C++20, 2026-12-01).
// Two rules, both must hold: the account is not blocked, and the number of// items is no more than the limit. `<=` because holding exactly the limit// is allowed: with a limit of 2, may_hold(2) is true and may_hold(3) false.// A blocked account says no to every number, even 1.bool MemberAccount::may_hold(int loans_held) const noexcept { return !blocked_ && loans_held <= loan_limit_;}may_hold takes the number of items the member would hold, rather than
looking it up. The account does not know about loans, and should not: that
would make it depend on the ledger, and give two classes a say in what a loan
is.
VerifiedCompiled and tested with GNU 11.4.0 and Clang 14.0.0 (C++20, 2026-12-01).
// One open loan: which copy, which member has it, and the day it is due// back. A plain value: the ledger stores it, and close() hands it back.struct Loan { std::string copy_id; std::string member_id; int due_day; // day number; the example counts days from an arbitrary start};
// Knows: every open loan, by copy ID.// Does: opens and closes loans; counts a member's loans.class LoanLedger {public: // Returns false, changing nothing, if loan.copy_id is already on loan. // The Loan is taken by value and moved into the map. bool open(Loan loan); // Returns the closed loan, or nothing if the copy was not on loan. // std::optional<Loan> either holds a Loan or is empty (std::nullopt); // the loan is removed from the ledger and handed back to the caller. std::optional<Loan> close(const std::string& copy_id);
// How many open loans this member has. It looks at every open loan, so // it takes time proportional to the number of loans (O(n)). [[nodiscard]] int count_for(const std::string& member_id) const;
private: // Open loans looked up by copy ID. One key per copy is what makes "a // copy can be on loan only once" true: a second open() for the same // copy finds the key taken. std::less<> works as in Catalog. std::map<std::string, Loan, std::less<>> by_copy_;};VerifiedCompiled and tested with GNU 11.4.0 and Clang 14.0.0 (C++20, 2026-12-01).
// Every way a checkout can end: lent, or refused for one named reason.// Refusals are ordinary outcomes (a member asks for a copy that is out), so// they are returned as values, not thrown as exceptions.enum class CheckoutResult { lent, no_such_copy, not_on_shelf, member_may_not_borrow };
// Does: carries out checkouts and returns, by asking its collaborators.// Knows: only the loan period, and who its collaborators are.class LoanDesk {public: // Binds the desk to the caller's catalog and ledger (no copies are made) // and remembers how many days a loan lasts. LoanDesk(Catalog& catalog, LoanLedger& ledger, int loan_days) noexcept : catalog_(catalog), ledger_(ledger), loan_days_(loan_days) {}
// Lends copy_id to member on day `today`, due back loan_days later, or // says why not. A refusal changes nothing. The member is passed to each // call, not stored, because one desk serves many members. CheckoutResult check_out(const MemberAccount& member, const std::string& copy_id, int today); // Returns false if the copy was not on loan. // Otherwise closes the loan, puts the copy back on the shelf, and // returns true. bool check_in(const std::string& copy_id);
private: // References, not copies: the desk works on the very catalog and ledger // that main created. A reference cannot be null or re-pointed, and the // two objects must outlive the desk. Catalog& catalog_; LoanLedger& ledger_; int loan_days_;};The desk holds references to the catalog and the ledger: it uses them, but
does not own them. The header comment says so, and main creates the catalog
and ledger before the desk, so they are destroyed after it and the references
never dangle. The member account is passed to each call instead, because a desk
serves many members.
VerifiedCompiled and tested with GNU 11.4.0 and Clang 14.0.0 (C++20, 2026-12-01).
// Asks first, changes last. The three checks only read; each one that fails// returns its reason at once, so later lines run only if every earlier// check passed, and a refused checkout changes nothing.CheckoutResult LoanDesk::check_out(const MemberAccount& member, const std::string& copy_id, int today) { if (!catalog_.owns(copy_id)) return CheckoutResult::no_such_copy; if (!catalog_.is_on_shelf(copy_id)) return CheckoutResult::not_on_shelf; // The ledger knows how many loans the member has now; "+ 1" counts the // copy being borrowed, and the account decides if that many is allowed. if (!member.may_hold(ledger_.count_for(member.id()) + 1)) { return CheckoutResult::member_may_not_borrow; } // A copy is on the shelf exactly when it has no open loan, so open() // succeeds here. If it throws (out of memory), nothing has changed yet. // {copy_id, member.id(), today + loan_days_} builds a Loan in field // order; the due day is today plus the loan period. ledger_.open({copy_id, member.id(), today + loan_days_}); // Cannot throw: owns(copy_id) was checked above. catalog_.mark_lent(copy_id); return CheckoutResult::lent;}
// The ledger decides whether the copy was out. close() returns an empty// optional if it was not, and `!` on an empty optional is true, so the// function returns false and changes nothing. The closed Loan itself is not// needed here, so the returned optional is destroyed straight away.bool LoanDesk::check_in(const std::string& copy_id) { if (!ledger_.close(copy_id)) return false; catalog_.mark_returned(copy_id); return true;}How this code works: LoanDesk::check_out and check_in
check_out has two halves: ask, then change.
- Ask the catalog. Does the library own this copy? Is it on the shelf?
Each
ifthat fails returns its reason at once, so nothing below it runs. - Ask the ledger, then the account.
ledger_.count_for(member.id())is how many items the member holds now. Adding 1 gives how many they would hold after this checkout, andmember.may_hold(...)decides whether that is allowed. The desk does the adding; the account makes the decision. - Change both collaborators. Only now does anything change: the ledger
opens a loan due on
today + loan_days_, and the catalog marks the copy as lent. Because every check came first, there is no path where one of the two changes and the other does not. Even ifopenran out of memory and threw, it would leave the ledger unchanged, and the catalog would not have been touched yet.
check_in runs the other way. The ledger is asked to close the loan; if there
was none, the function returns false and changes nothing. Otherwise the
catalog puts the copy back on the shelf.
A worked example: the five calls in main. The desk lends for 21 days.
M-1 (ada) may hold 1 item; M-2 (alan) may hold 3.
| Call | Owns? | On shelf? | Loans held + 1 | may_hold? |
Result |
|---|---|---|---|---|---|
| M-1 borrows C-1 on day 100 | yes | yes | 0 + 1 = 1 | 1 ≤ 1: yes | lent, due day 121 |
| M-2 borrows C-1 on day 100 | yes | no | not asked | not asked | not_on_shelf |
| M-1 borrows C-2 on day 100 | yes | yes | 1 + 1 = 2 | 2 ≤ 1: no | member_may_not_borrow |
| C-1 returned | true: back on shelf |
||||
| M-2 borrows C-1 on day 101 | yes | yes | 0 + 1 = 1 | 1 ≤ 3: yes | lent, due day 122 |
check_out reads like the behaviour description, line by line. Every question
is asked of the object that knows the answer, and the desk only decides the
order and the result. It also keeps one rule that spans two collaborators: a
copy is on the shelf exactly when it has no open loan. Because, in this design, the
desk is the only code that changes both, the rule has one owner.
The collaboration
Section titled “The collaboration”Text description of the diagram
During a checkout, the LoanDesk sends every message; the other three classes
only answer or record. In order: the desk asks the Catalog whether the library
owns the copy and whether it is on the shelf; asks the LoanLedger how many
loans the member already has; asks the MemberAccount whether the member may
hold one more; tells the LoanLedger to open the loan; and tells the Catalog
to mark the copy as lent. The Catalog, LoanLedger, and MemberAccount never
call each other.
Diagram source (Mermaid)
flowchart LR
Desk[LoanDesk] -->|"1. owns copy? 2. on shelf?"| Cat[Catalog]
Desk -->|"3. how many loans?"| Led[LoanLedger]
Desk -->|"4. may hold one more?"| Acc[MemberAccount]
Desk -->|"5. open loan"| Led
Desk -->|"6. mark lent"| CatAll arrows start at the desk. The three other classes do not know each other exist, so each can be changed, or tested, on its own. That is low coupling between them, paid for by the desk, which depends on all three.
VerifiedCompiled and tested with GNU 11.4.0 and Clang 14.0.0 (C++20, 2026-12-01).
// The catalog and ledger are created before the desk that refers to// them, so they are destroyed after it. Loans last 21 days.Catalog catalog;catalog.add("C-1", "Dune");catalog.add("C-2", "Emma");LoanLedger ledger;LoanDesk desk(catalog, ledger, 21);
MemberAccount ada("M-1", 1); // may hold one item at a timeMemberAccount alan("M-2", 3);
// describe() (defined above main) turns a CheckoutResult into text.// Day 100: M-1 takes C-1. Then M-2 asks for C-1, which is now out, and// M-1 asks for C-2 but already holds their one allowed item.std::cout << "M-1 borrows C-1: " << describe(desk.check_out(ada, "C-1", 100)) << '\n';std::cout << "M-2 borrows C-1: " << describe(desk.check_out(alan, "C-1", 100)) << '\n';std::cout << "M-1 borrows C-2: " << describe(desk.check_out(ada, "C-2", 100)) << '\n';// C-1 comes back, so on day 101 M-2 can borrow it. `?:` picks "yes" if// check_in returned true, otherwise "no".std::cout << "C-1 returned: " << (desk.check_in("C-1") ? "yes" : "no") << '\n';std::cout << "M-2 borrows C-1: " << describe(desk.check_out(alan, "C-1", 101)) << '\n';M-1 borrows C-1: lentM-2 borrows C-1: refused: copy is not on the shelfM-1 borrows C-2: refused: member may not borrow moreC-1 returned: yesM-2 borrows C-1: lentTesting responsibilities
Section titled “Testing responsibilities”VerifiedCompiled and tested with GNU 11.4.0 and Clang 14.0.0 (C++20, 2026-12-01).
// LLD_TEST(name) defines one test. LLD_CHECK(condition) records a failure if// the condition is false. LLD_CHECK_EQ(actual, expected) records a failure// unless the two are equal, and prints both. LLD_CHECK_THROWS(expression,// type) fails unless the expression throws that type of exception. They come// from the site's small test header, lld_test.hpp.
// The account alone, no desk: with a limit of 2, holding 2 is allowed and// 3 is not; blocking refuses even 1; unblocking allows it again.LLD_TEST(account_decides_its_own_limit_and_standing) { MemberAccount account("M-1", 2); LLD_CHECK(account.may_hold(2)); LLD_CHECK(!account.may_hold(3)); account.block(); LLD_CHECK(!account.may_hold(1)); account.unblock(); LLD_CHECK(account.may_hold(1));}
// The ledger alone: two loans for M-1 open; a second loan of C-2 (to M-2)// is refused because C-2 is already out. close() hands back the loan it// removed, and closing the same copy again gives an empty optional.LLD_TEST(ledger_counts_loans_per_member) { LoanLedger ledger; LLD_CHECK(ledger.open({"C-1", "M-1", 10})); LLD_CHECK(ledger.open({"C-2", "M-1", 10})); LLD_CHECK(!ledger.open({"C-2", "M-2", 10})); // already on loan LLD_CHECK_EQ(ledger.count_for("M-1"), 2); LLD_CHECK_EQ(ledger.count_for("M-2"), 0); const auto closed = ledger.close("C-1"); // `closed->member_id` reads a field of the Loan inside the optional; // has_value() is checked first, and && stops early if it is false. LLD_CHECK(closed.has_value() && closed->member_id == "M-1"); LLD_CHECK(!ledger.close("C-1").has_value());}
// A successful checkout changes both collaborators: the catalog shows the// copy as out, the ledger has one loan for the member, and that loan is due// on day 100 + 21 = 121.LLD_TEST(desk_sets_the_due_day_and_updates_both_collaborators) { Catalog catalog; catalog.add("C-1", "Dune"); LoanLedger ledger; LoanDesk desk(catalog, ledger, 21); const MemberAccount member("M-1", 5);
LLD_CHECK(desk.check_out(member, "C-1", 100) == CheckoutResult::lent); LLD_CHECK(!catalog.is_on_shelf("C-1")); LLD_CHECK_EQ(ledger.count_for("M-1"), 1); const auto loan = ledger.close("C-1"); LLD_CHECK(loan.has_value() && loan->due_day == 121);}
// Refusals change nothing. The member is blocked, so an unknown copy is// refused as no_such_copy (that check comes first), and a real copy as// member_may_not_borrow. Afterwards C-1 is still on the shelf, M-1 has no// loans, and check_in reports that C-1 was never out.LLD_TEST(desk_refusals_change_nothing) { Catalog catalog; catalog.add("C-1", "Dune"); LoanLedger ledger; LoanDesk desk(catalog, ledger, 21); MemberAccount member("M-1", 1); member.block();
LLD_CHECK(desk.check_out(member, "C-9", 100) == CheckoutResult::no_such_copy); LLD_CHECK(desk.check_out(member, "C-1", 100) == CheckoutResult::member_may_not_borrow); LLD_CHECK(catalog.is_on_shelf("C-1")); LLD_CHECK_EQ(ledger.count_for("M-1"), 0); LLD_CHECK(!desk.check_in("C-1")); // was never lent}
// The shelf check: once C-1 is lent to M-1, M-2 is refused, and the ledger// still shows the one loan with M-1 and none with M-2.LLD_TEST(desk_refuses_a_copy_that_is_out) { Catalog catalog; catalog.add("C-1", "Dune"); LoanLedger ledger; LoanDesk desk(catalog, ledger, 21); const MemberAccount first("M-1", 1); const MemberAccount second("M-2", 1);
LLD_CHECK(desk.check_out(first, "C-1", 100) == CheckoutResult::lent); LLD_CHECK(desk.check_out(second, "C-1", 101) == CheckoutResult::not_on_shelf); LLD_CHECK_EQ(ledger.count_for("M-1"), 1); LLD_CHECK_EQ(ledger.count_for("M-2"), 0);}
// The catalog alone: an ID can be added once; an unknown copy is not on// the shelf; and mark_lent on an unknown copy throws, as its comment says.LLD_TEST(catalog_rejects_unknown_copies) { Catalog catalog; LLD_CHECK(catalog.add("C-1", "Dune")); LLD_CHECK(!catalog.add("C-1", "Emma")); LLD_CHECK(!catalog.is_on_shelf("C-9")); LLD_CHECK_THROWS(catalog.mark_lent("C-9"), std::out_of_range);}The tests follow the cards. The account, the ledger, and the catalog are each tested alone, with no desk, because they do not need one. The desk’s tests check the coordination: a successful checkout updates both collaborators and sets the due day, and each refusal (an unknown copy, a copy already out, a blocked member) changes nothing.
Other ways to divide the work
Section titled “Other ways to divide the work”One big class. A single Library class with maps of copies, members, and
loans, and a check_out function, would be shorter. For a 50-line script, that
can be fine. It stops being fine as behaviour grows. Fines, holds, renewals, and
reports all land in the same class, every change risks every other feature, and
nothing can be tested without building the whole library. The
single-responsibility lesson returns to this.
Members who know their loans. Each MemberAccount could keep a list of its
own loans, making question 3 trivial. But then loans live in two places, the
member’s list and whatever answers “who has copy C-1?”, and the two must be
kept in step. Here, one class knows loans, and counting is a search through
the ledger. That search is O(n) in the number of open loans. If that ever
matters, the ledger can keep a count per member, a change hidden inside the
ledger.
A smarter catalog. The catalog could check the member’s limit itself, as
part of mark_lent. That would put a member rule in a class about copies, and
make the catalog depend on members. Rules about members belong with members.
Common mistakes
Section titled “Common mistakes”- A class for every noun. Some nouns are values (a due date), some are fields (a shelf), and some are outside the software (the librarian).
- Classes that only hold data, with all the logic in one “manager”. The data and the rules about it drift apart.
- Responsibilities that need an “and” to describe, such as “knows copies and decides fines”. It is usually two classes.
- Asking for data and deciding elsewhere, such as
if (account.limit() > n)in the desk. Ask the object that knows to decide:account.may_hold(n). - Everyone talks to everyone. If every class calls every other, nothing can be changed or tested alone.
When a requirement changes
Section titled “When a requirement changes”New requirement: “A member with an overdue loan may not borrow anything until it is returned.”
First question: who knows whether a member has an overdue loan? The ledger:
it knows every loan’s member and due day. So the ledger gains a knowing
responsibility, has_overdue(member_id, today), and the desk asks one more
question before lending. The catalog and the account do not change. The rule’s
cost, a new function in the ledger and one more line in the desk, shows that
the responsibilities were placed where this kind of change expects them.
If the new rule had instead been put inside MemberAccount, the account would
have needed to know about loans, and two classes would know about due days.
Exercise: Write CRC cards for holds
New behaviour:
When every copy of a title is out, a member can place a hold on the title. Members are served in the order they placed holds. When a copy of that title is returned, it is not put back on the shelf: it is kept for the first member waiting, who is sent a message, and it is released to the shelf if they do not collect it within 3 days.
- List the knowing and doing responsibilities this adds.
- Write the CRC cards: which existing classes change, and which new ones are needed?
- Which nouns in the description did you not turn into classes, and why?
Show the explained answer
-
Responsibilities. Knowing: which members wait for each title, in order; which copy is kept for which member, and until which day. Finding the holds for a returned copy also needs the copy’s title, which the catalog already stores. Doing: place a hold; on return, find the first waiting member and keep the copy for them; send them a message; release kept copies that were not collected in time.
-
Cards. One reasonable set:
Class Responsibilities Collaborators HoldQueue(new)Knows waiting members per title, in order. Adds a hold; removes and returns the next member for a title. none Catalog(changed)Gains a way to look up a copy’s title (it already stores it). Also knows whether a copy is kept for a member, and until when. none Notifier(new)Sends a member a message. the actual messaging system LoanDesk(changed)Also places holds, and on return decides between shelf and hold. Catalog,LoanLedger,HoldQueue,NotifierThe 3-day release is a doing responsibility that something must run each day: a small
HoldExpirystep, or a desk function called by a daily job, asking the catalog for kept copies whose day has passed.MemberAccountandLoanLedgerdo not change; a hold is not a loan.Check the desk card: it now has four collaborators and more decisions. That is a sign to watch, as the trade-off box warns. If it keeps growing, the return process could become its own coordinator.
-
Not classes: message (a value the notifier sends, perhaps a string at first), 3 days (a setting, like the loan period), order (a property of the queue, not a thing). Hold might become a small value (member and title) in the queue, but it needs no behaviour of its own yet.
Summary
Section titled “Summary”- A class describes many objects; design by thinking about what each object knows and does.
- Start from behaviour. List the questions it must answer (knowing responsibilities) and the actions it must take (doing responsibilities).
- Give each responsibility to the object that has the information it needs, and let a coordinator decide the order, not the rules.
- CRC cards (class, responsibilities, collaborators) are a cheap way to try and test a design before writing code.
- Not every noun is a class.