These are the notes for Low-Level Design (LLD) episode 55. Fifty-four episodes gave us the tools (classes, interfaces, SOLID, patterns, testing, error handling). Now we use them against the clock. On one practice prompt, a college library's book lending, we first code the obvious way and watch it break, then build a repeatable method: the machine-coding round format, time-boxing, clarifying requirements, scoping the MVP, identifying entities and relationships, interfaces first, in-memory repositories, a driver class and a demo main, handling edge cases, extensibility talking points, common mistakes and what interviewers score.
How the code was run: every program with javac Main.java && java -cp . Main on OpenJDK 21. All outputs are real.
Sources for facts about the round (fetched 10 Nov 2026): the dev.to article Machine Coding Round: What & How to Crack It (Tutort Academy) and PracHub's Machine Coding Round Guide 2026: Requirements, Architecture, Tests and Working Code. Both are preparation guides, not official company rules.
1. What a machine-coding round is
- You get a product-style problem (a parking lot, a library, a cab booking, a snake-and-ladder game) and must turn it into working, runnable code in a fixed time. Not pseudocode: code that compiles and runs.
- Length: the dev.to guide says the round is held within "a limited time frame, usually 60 to 90 minutes". PracHub warns "There is no universal industry format"; as one example it describes Flipkart's published SDE guide as "a 120-minute round with 15 minutes of clarification, 90 minutes of coding". Your invitation and recruiter instructions override every generic guide.
- At the end you run it, demo it and explain it; PracHub notes "the interviewer can usually execute your solution, enter a new test case, change a requirement."
- Compare the design discussion round (episode 1): there you talk and draw. In machine coding you talk and it must run.
2. Today's practice prompt
Design a book-lending system for a college library.
- The library adds books. A book can have several copies.
- A member can borrow a book if a copy is free.
- A member can return a book.
- Show how many copies of a book are available.
Write working code. You have 90 minutes.
The interviewer may add requirements on the way.
3. The obvious attempt: coding at minute 2
import java.util.*;
public class Main { // minute 2: straight into main()
public static void main(String[] args) {
Map<String, Integer> copies = new HashMap<>();
copies.put("Clean Code", 3);
copies.put("Head First Java", 1);
List<String> borrowed = new ArrayList<>(); // "member:title"
copies.put("Head First Java", copies.get("Head First Java") - 1); borrowed.add("Ravi:Head First Java");
copies.put("Clean Code", copies.get("Clean Code") - 1); borrowed.add("Asha:Clean Code");
// minute 60, the interviewer: "Neha borrows Head First Java. Asha takes two more Clean Codes."
copies.put("Head First Java", copies.get("Head First Java") - 1); borrowed.add("Neha:Head First Java");
copies.put("Clean Code", copies.get("Clean Code") - 1); borrowed.add("Asha:Clean Code");
copies.put("Clean Code", copies.get("Clean Code") - 1); borrowed.add("Asha:Clean Code");
System.out.println(copies);
System.out.println(borrowed);
}
}
Output (real):
{Clean Code=0, Head First Java=-1}
[Ravi:Head First Java, Asha:Clean Code, Neha:Head First Java, Asha:Clean Code, Asha:Clean Code]
The library lent a book it didn't have (Head First Java=-1) and Asha holds three Clean Codes. Then the interviewer asks "can a member hold more than two books?" and there is nowhere to put that rule: the borrow logic exists five times.
Why it failed:
- No questions: the two-book limit was never asked.
- No entities: an entity is a thing in the problem with its own identity and data (a book, a member). Here a book is a map entry and a loan is a string.
- No single home for rules: borrow logic pasted five times; change one, four are wrong.
- No plan for time: a twist at minute 60 became a panic.
The fix is not typing faster. It is a method.
4. The real-life idea: cooking for a wedding in 90 minutes
| In the kitchen | In the round |
|---|---|
| Ask: veg or non-veg? How many guests? | Clarify requirements; write assumptions |
| Dal, rice, one sabzi first; sweets only if time is left | MVP: the smallest useful version |
| Rice must be ready by 7:30 | Time-boxing: a fixed slot per phase |
| Taste before serving, not after the guests leave | Demo main: run it end to end, early and often |
5. Time-boxing: a 90-minute plan
Time-boxing means giving each phase a fixed time slot and moving on when it ends, even if the phase isn't perfect.
PracHub's 90-minute practice plan ("a PracHub practice schedule, not an official rubric"):
| Minutes | Phase | Output |
|---|---|---|
| 0-10 | Clarify | Requirements, priorities, constraints, explicit non-goals |
| 10-18 | Design | A small class map, interfaces, data model, how you'll run it |
| 18-55 | Build a vertical slice | The main path working end to end, then the other core operations |
| 55-75 | Harden | Validation, important edge cases, focused tests, a readability pass |
| 75-90 | Demo | Clean run, demo script, explanation, trade-offs, next extension |
Scale the numbers to your round. Keep the order: understand, design, run, harden, show. Code that runs at minute 30 beats perfect code that never runs.
6. Clarifying requirements (minutes 0-10)
A requirement is something the system must do (episode 20: functional requirements are features; non-functional ones are qualities like speed or thread safety). Clarifying means asking until the rules and the scope are clear.
Q: Can a member borrow two copies of the same book? A: Yes.
Q: Is there a limit per member? A: Yes, 2 books at a time.
Q: What if no copy is free? A: Refuse with a reason.
Q: Do we need fines, reservations, due dates? A: Not now. Maybe later.
Q: One library branch or many? A: One.
Q: Store data in a database? A: No, in memory is fine.
Q: Command line, or just a demo main()? A: A demo main() is fine.
Q: Many counters at the same time (threads)? A: Not for now.
// ASSUMPTIONS (written at the top of the code)
// member = a name; book = ISBN + title + copies; one branch; in memory
- Ask about rules (limits, what happens on failure) and about scope (fines? many branches? database? threads?). Every answer adds or removes work.
- An assumption is a choice you make yourself when the prompt is silent. State it out loud and write it at the top of the code so it can be corrected early.
7. Scoping the MVP
The MVP (minimum viable product) is the smallest version that is actually useful.
| Must-have (build now) | Later (talking points) |
|---|---|
| Add books with copies | Returns |
| Borrow, with the 2-book limit | Fines, due dates, reservations |
| Copies available | Many branches |
| Refuse with a clear reason | A database, threads, a command-line menu |
Say it out loud: "I'll build these first; these are next." Interviewers want to see you prioritise.
8. Entities and relationships (minutes 10-18)
- Nouns in the prompt are candidate entities (episode 20): library, book, copy, member, loan.
- Relationships say how entities connect: a member has loans; a loan points to one book.
- Multiplicity (episode 18) says how many: one member has 0..2 loans; many loans can point to one book.
- Verbs become behaviour:
borrow(),available()on aLibraryservice (a class that holds the rules). - Where data is kept goes behind a
BookRepository.
Member 1 ──── 0..2 Loan * ──── 1 Book(isbn, title, copies)
│
Library (rules) ──uses──> BookRepository <<interface>> <|── InMemoryBookRepository
9. Interfaces first
Interfaces first means writing the types and method signatures before any method bodies. The result is a skeleton: the whole shape of the design, compiling.
import java.util.*;
record Book(String isbn, String title, int copies) {} // entity: plain data
interface BookRepository { // where books are kept
Optional<Book> find(String isbn);
void save(Book book);
}
class Library { // what the library does
Library(BookRepository books) { }
void borrow(String member, String isbn) { throw new UnsupportedOperationException("TODO"); }
int available(String isbn) { throw new UnsupportedOperationException("TODO"); }
}
public class Main {
public static void main(String[] args) {
System.out.println("minute 18: the design compiles");
new Library(null).borrow("Ravi", "B2");
}
}
Output (real):
minute 18: the design compiles
Exception in thread "main" java.lang.UnsupportedOperationException: TODO
at Library.borrow(Main.java:9)
at Main.main(Main.java:15)
The design compiles at minute 18; every later minute fills a body instead of moving things around, and you can walk the interviewer through the whole design already.
10. In-memory repositories
- A repository (episode 45) is an object that looks like a collection of saved entities:
find,save. - An in-memory repository keeps them in a
HashMapinside the program. Data disappears when the program ends; that's fine for the round, and it avoids spending your 90 minutes on database setup. Librarydepends only on theBookRepositoryinterface (dependency inversion, episode 16). A database later = a new class implementing the same interface;Librarydoesn't change.
11. A vertical slice and a demo main (minutes 18-55)
A vertical slice is one complete path through every layer (main → Library → repository → back). A demo main is a main method that runs the main flow end to end and prints the state.
import java.util.*;
record Book(String isbn, String title, int copies) {}
interface BookRepository { Optional<Book> find(String isbn); void save(Book book); }
class InMemoryBookRepository implements BookRepository { // a HashMap standing in for a database
private final Map<String, Book> rows = new HashMap<>();
public Optional<Book> find(String isbn) { return Optional.ofNullable(rows.get(isbn)); }
public void save(Book book) { rows.put(book.isbn(), book); }
}
class Library {
private final BookRepository books;
Library(BookRepository books) { this.books = books; } // depends on the interface only
void borrow(String member, String isbn) {
Book b = books.find(isbn).orElseThrow();
books.save(new Book(isbn, b.title(), b.copies() - 1));
}
}
public class Main { // demo main: the main flow, end to end
public static void main(String[] args) {
BookRepository repo = new InMemoryBookRepository(); Library lib = new Library(repo);
repo.save(new Book("B2", "Head First Java", 1));
lib.borrow("Ravi", "B2");
System.out.println("after Ravi: " + repo.find("B2").get());
lib.borrow("Neha", "B2"); // and one more, to be sure
System.out.println("after Neha: " + repo.find("B2").get());
}
}
Output (real):
after Ravi: Book[isbn=B2, title=Head First Java, copies=0]
after Neha: Book[isbn=B2, title=Head First Java, copies=-1]
The demo caught copies=-1 at minute 30, before the interviewer could.
12. Edge cases and a driver class (minutes 55-75)
An edge case is an unusual input at the limits of the rules. For the library: no copy left, a member at the 2-book limit, an unknown ISBN. Always try the usual suspects: zero, negative, null, empty, duplicates, the same action twice.
Handle them with episode 54's tools: guard clauses that fail fast, in one place (Library), throwing a domain exception with a clear reason.
A driver class is a class whose only job is to drive the system through scripted scenarios and print the results. Here Main is the driver and step prints OK or NO with the reason.
import java.util.*;
record Book(String isbn, String title, int copies) {}
interface BookRepository { Optional<Book> find(String isbn); void save(Book book); }
class InMemoryBookRepository implements BookRepository { // same as before
private final Map<String, Book> rows = new HashMap<>();
public Optional<Book> find(String isbn) { return Optional.ofNullable(rows.get(isbn)); }
public void save(Book book) { rows.put(book.isbn(), book); } }
class LibraryException extends RuntimeException { LibraryException(String m) { super(m); } }
class Library {
static final int MAX_LOANS = 2;
private final BookRepository books; private final Map<String, Integer> loans = new HashMap<>();
Library(BookRepository books) { this.books = books; }
void borrow(String member, String isbn) {
Book b = books.find(isbn).orElseThrow(() -> new LibraryException("no book " + isbn));
if (loans.getOrDefault(member, 0) == MAX_LOANS) throw new LibraryException(member + " has 2 books");
if (b.copies() == 0) throw new LibraryException("no copy of " + b.title() + " left");
books.save(new Book(isbn, b.title(), b.copies() - 1)); loans.merge(member, 1, Integer::sum);
} }
public class Main { // the driver: a scripted demo
static void step(String what, Runnable action) {
try { action.run(); System.out.println("OK " + what); }
catch (LibraryException e) { System.out.println("NO " + what + ": " + e.getMessage()); } }
public static void main(String[] args) {
BookRepository repo = new InMemoryBookRepository(); Library lib = new Library(repo);
repo.save(new Book("B1", "Clean Code", 3)); repo.save(new Book("B2", "Head First Java", 1));
step("Ravi borrows Head First Java", () -> lib.borrow("Ravi", "B2"));
step("Neha borrows Head First Java", () -> lib.borrow("Neha", "B2"));
step("Asha borrows Clean Code 3 times", () -> { for (int i = 0; i < 3; i++) lib.borrow("Asha", "B1"); });
step("Priya asks for ISBN B9", () -> lib.borrow("Priya", "B9")); } }
Output (real):
OK Ravi borrows Head First Java
NO Neha borrows Head First Java: no copy of Head First Java left
NO Asha borrows Clean Code 3 times: Asha has 2 books
NO Priya asks for ISBN B9: no book B9
(On screen the program had to fit one editor page, so Library counts loans per member in a Map<String, Integer> and returns are left for the follow-ups.)
The full submission with returns (a longer, real run)
import java.util.*;
record Book(String isbn, String title, int copies) {}
interface BookRepository { Optional<Book> find(String isbn); void save(Book book); }
class InMemoryBookRepository implements BookRepository { // a database can replace it later
private final Map<String, Book> rows = new HashMap<>();
public Optional<Book> find(String isbn) { return Optional.ofNullable(rows.get(isbn)); }
public void save(Book book) { rows.put(book.isbn(), book); }
}
class LibraryException extends RuntimeException { LibraryException(String m) { super(m); } }
class Library {
private final BookRepository books; private final Map<String, List<String>> loans = new HashMap<>();
Library(BookRepository books) { this.books = books; }
void borrow(String member, String isbn) {
Book b = books.find(isbn).orElseThrow(() -> new LibraryException("no book " + isbn));
List<String> mine = loans.computeIfAbsent(member, m -> new ArrayList<>());
if (mine.size() == 2) throw new LibraryException(member + " already has 2 books");
if (b.copies() == 0) throw new LibraryException("no copy of " + b.title() + " left");
books.save(new Book(isbn, b.title(), b.copies() - 1)); mine.add(isbn);
}
void giveBack(String member, String isbn) {
if (!loans.getOrDefault(member, new ArrayList<>()).remove(isbn))
throw new LibraryException(member + " never borrowed " + isbn);
Book b = books.find(isbn).orElseThrow(); books.save(new Book(isbn, b.title(), b.copies() + 1));
}
}
public class Main { // the driver: a scripted demo
static void step(String what, Runnable action) {
try { action.run(); System.out.println("OK " + what); }
catch (LibraryException e) { System.out.println("NO " + what + ": " + e.getMessage()); }
}
public static void main(String[] args) {
BookRepository repo = new InMemoryBookRepository(); Library lib = new Library(repo);
repo.save(new Book("B1", "Clean Code", 3)); repo.save(new Book("B2", "Head First Java", 1));
step("Ravi borrows Head First Java", () -> lib.borrow("Ravi", "B2"));
step("Neha borrows Head First Java", () -> lib.borrow("Neha", "B2"));
step("Priya returns Clean Code", () -> lib.giveBack("Priya", "B1"));
step("Asha borrows 3 copies", () -> { lib.borrow("Asha", "B1"); lib.borrow("Asha", "B1"); lib.borrow("Asha", "B1"); });
step("Ravi returns Head First Java", () -> lib.giveBack("Ravi", "B2"));
System.out.println("Clean Code left: " + repo.find("B1").get().copies() + ", Head First Java left: " + repo.find("B2").get().copies());
}
}
Output (real):
OK Ravi borrows Head First Java
NO Neha borrows Head First Java: no copy of Head First Java left
NO Priya returns Clean Code: Priya never borrowed B1
NO Asha borrows 3 copies: Asha already has 2 books
OK Ravi returns Head First Java
Clean Code left: 1, Head First Java left: 1
13. The submitted layout
library/
model/ Book.java Loan.java (records: plain data)
repository/ BookRepository.java (interfaces first)
InMemoryBookRepository.java (HashMap today, a database tomorrow)
service/ Library.java (the rules live here, and only here)
exception/ LibraryException.java
Main.java (the driver: scripted demo)
Run: javac -d out $(find . -name "*.java") && java -cp out Main
Always give the run command. PracHub lists "Ignoring the run command" among common mistakes: it "leaves the interviewer debugging your setup".
14. Extensibility talking points (minutes 75-90)
Extensibility is how easily new features can be added. Prepare one sentence per likely change; each names the seam (where the change plugs in), the new class, and what stays untouched.
| Follow-up | Talking point |
|---|---|
| "Use a real database" | "A new BookRepository implementation; Library is untouched." |
| "Add late fines" | "A FinePolicy interface (Strategy, episode 34): one class per kind of fine." |
| "Tell a student when a book comes back" | "Observer (episode 35): waiting members subscribe to the book." |
| "Two counters at once" | "Make borrow atomic (episodes 46-50)." |
Episode 56 answers these follow-ups in code.
15. What interviewers score
PracHub names five signals and calls them "a preparation model, not a universal company scorecard":
| Signal | PracHub's description |
|---|---|
| Requirements | "You identify the core flow, constraints, invalid cases, and what is explicitly out of scope." |
| Architecture | "Responsibilities are separated enough that a change stays local and the code remains easy to trace." |
| Correctness | "The program runs, the main path works end to end, and failures are handled deliberately." |
| Testing | Tests or a deterministic driver that prove "important behavior, boundaries, and state transitions." |
| Judgment | "You prioritize the highest-value behavior, explain trade-offs, and avoid speculative complexity." |
The dev.to guide adds that interviewers look for "code quality, clarity, and efficiency": readable names, modular functions, handled edge cases, and explaining your thought process and trade-offs out loud.
A deterministic driver gives the same output on every run for the same input (no randomness, no real clock), so the interviewer can trust it.
Common mistakes
| Mistake | What you see | Why | Fix |
|---|---|---|---|
| Coding at minute 2 | {Clean Code=0, Head First Java=-1}; the 2-book rule missed |
No clarifying questions | Ask, write assumptions |
Everything in main() |
Borrow logic pasted 5 times | No entities, no home for rules | Entities + a service |
| Twelve patterns before it runs | Minute 80: nothing compiles | Over-designing first | Slice first, then extend |
| Testing only at the end | copies=-1 found by the interviewer |
No demo main | Run end to end early |
| Hiding what's unfinished | "It works"... it doesn't | Damages trust | Say what's done and what's next |
| No run command | The interviewer can't start it | Setup left to them | One line in the README |
PracHub's own list of mistakes includes "Coding before the scope is stable", "Over-designing before the first run", "Testing only at the end", "Ignoring the run command", "Hiding unfinished behavior" and "optimizing for pattern count".
Mini project: a canteen token counter in 45 minutes
Prompt: customers take a numbered token, the counter serves the oldest waiting token, a token can be cancelled. Clarified: one counter; numbers start at 1; one open token per customer; in memory. Time-box: 5 min clarify, 5 min design, 20 min slice, 10 min edge cases, 5 min demo.
import java.util.*;
// ASSUMPTIONS: one counter; tokens start at 1 each day; a customer may hold one open token; in memory.
record Token(int number, String customer) {}
interface TokenRepository {
void save(Token t);
Optional<Token> next(); // oldest waiting token
boolean remove(int number);
Optional<Token> byCustomer(String customer);
List<Token> waiting();
}
class InMemoryTokenRepository implements TokenRepository {
private final LinkedHashMap<Integer, Token> rows = new LinkedHashMap<>(); // keeps arrival order
public void save(Token t) { rows.put(t.number(), t); }
public Optional<Token> next() { return rows.values().stream().findFirst(); }
public boolean remove(int number) { return rows.remove(number) != null; }
public Optional<Token> byCustomer(String c) { return rows.values().stream().filter(t -> t.customer().equals(c)).findFirst(); }
public List<Token> waiting() { return List.copyOf(rows.values()); }
}
class CounterException extends RuntimeException { CounterException(String m) { super(m); } }
class TokenCounter {
private final TokenRepository tokens;
private int lastNumber = 0;
TokenCounter(TokenRepository tokens) { this.tokens = Objects.requireNonNull(tokens); }
Token issue(String customer) {
if (customer == null || customer.isBlank()) throw new CounterException("customer name is required");
if (tokens.byCustomer(customer).isPresent()) throw new CounterException(customer + " already has a token");
Token t = new Token(++lastNumber, customer);
tokens.save(t);
return t;
}
Token serveNext() {
Token t = tokens.next().orElseThrow(() -> new CounterException("nobody is waiting"));
tokens.remove(t.number());
return t;
}
void cancel(int number) {
if (!tokens.remove(number)) throw new CounterException("no waiting token " + number);
}
List<Token> waiting() { return tokens.waiting(); }
}
public class Main { // driver class: scripted scenarios
static void step(String what, Runnable action) {
try { action.run(); System.out.println("OK " + what); }
catch (CounterException e) { System.out.println("NO " + what + ": " + e.getMessage()); }
}
public static void main(String[] args) {
TokenCounter counter = new TokenCounter(new InMemoryTokenRepository());
step("Asha takes a token", () -> System.out.print(" -> " + counter.issue("Asha") + "\n"));
step("Ravi takes a token", () -> counter.issue("Ravi"));
step("Asha takes another", () -> counter.issue("Asha"));
step("Neha takes a token", () -> counter.issue("Neha"));
step("Ravi cancels token 2", () -> counter.cancel(2));
step("cancel token 9", () -> counter.cancel(9));
step("serve next", () -> System.out.print(" -> served " + counter.serveNext() + "\n"));
step("serve next", () -> System.out.print(" -> served " + counter.serveNext() + "\n"));
step("serve next", () -> counter.serveNext());
step("blank name", () -> counter.issue(" "));
System.out.println("waiting now: " + counter.waiting());
}
}
Output (real):
-> Token[number=1, customer=Asha]
OK Asha takes a token
OK Ravi takes a token
NO Asha takes another: Asha already has a token
OK Neha takes a token
OK Ravi cancels token 2
NO cancel token 9: no waiting token 9
-> served Token[number=1, customer=Asha]
OK serve next
-> served Token[number=3, customer=Neha]
OK serve next
NO serve next: nobody is waiting
NO blank name: customer name is required
waiting now: []
Practice
1. Write eight clarifying questions for "Design a parking lot".
Answer
How many floors and spots? Which vehicle types (bike, car, truck) and spot sizes? Can a small vehicle use a bigger spot? How is the fee calculated (per hour, first hour free, daily cap)? Entry and exit gates: how many? Payment methods in scope? What happens when the lot is full? Do we need a display board of free spots? Single lot or many? In memory, or a database? Concurrent entries at several gates?
2. Your round is 60 minutes. Write a time-boxed plan.
Answer
0-7 clarify and write assumptions; 7-12 entities, interfaces, skeleton that compiles; 12-37 vertical slice with a demo main; 37-50 edge cases with a driver; 50-60 clean run, demo, talking points.
3. Which of these belong in the MVP of the library? Returns, the 2-book limit, fines, reservations, copies available.
Answer
The 2-book limit and copies available (agreed as must-haves). Returns are core to lending and often next; fines and reservations are "later" talking points unless the interviewer says otherwise.
4. Why put BookRepository behind an interface even though the round only needs a HashMap?
Answer
So Library depends on an abstraction: a database version (or a fake for tests) can replace the in-memory one without changing Library, which is the first follow-up most interviewers ask.
5. Add returns to the mini project's token counter: what edge cases would you test?
Answer
Serving when nobody waits, cancelling an unknown or already-served token, a customer taking a second token, a blank name, cancelling then taking a new token, token numbers never reused in a day.
Quick quiz
90-minute round, minute 50: borrow() works and the demo runs. Not done: returns, the 2-book limit (a must-have), fines (agreed as "later"). What next? (a) Start fines (b) Add the 2-book limit and its edge cases (c) Rewrite everything with the Builder pattern (d) Stop and wait for questions
Answer
(b). The limit was a must-have from the clarifying questions; fines were agreed as later. Finish the MVP and its edge cases, keep the demo green, and mention fines as a talking point.
Interview questions
- How do you start a machine-coding round? Restate the problem, ask clarifying questions about rules and scope, write assumptions, agree the MVP, then sketch entities and interfaces.
- How do you manage time? Time-box each phase; get a vertical slice running early; leave the last minutes for a clean run and the demo.
- Why in-memory storage? It is fast to build and enough for the round; a repository interface makes a database a later swap.
- How do you show your code works without a test framework? A deterministic driver class / demo main with scripted scenarios, including failure cases, printing OK/NO with reasons.
- What if you run out of time? Make sure what exists runs; say clearly what's done and what's left, and explain how you'd finish it.
- How much design is too much? Patterns only where something really varies; no layers or factories without a requirement asking for them.
Glossary
| Term | Meaning, with an example |
|---|---|
| Machine-coding round | An interview where a product-style problem must become working code in fixed time |
| Design discussion round | An interview where you discuss and draw a design without running code |
| Time-boxing | A fixed time slot per phase; move on when it ends: 0-10 min clarify |
| Requirement | Something the system must do: "a member can borrow a book" |
| Clarifying question | A question that settles a rule or the scope: "Is there a limit per member?" |
| Assumption | A choice you make when the prompt is silent, written down: "member = a name" |
| Scope | What is in and out of this version |
| MVP | Minimum viable product: the smallest useful version |
| Non-goal | Something explicitly out of scope: fines, for now |
| Entity | A thing with identity and data: Book(isbn, title, copies) |
| Relationship | How entities connect: a loan points to a book |
| Multiplicity | How many on each side: a member has 0..2 loans |
| Service | A class that holds the rules: Library |
| Interfaces first | Write types and signatures before bodies |
| Skeleton | The whole design with empty bodies that compiles: throw new UnsupportedOperationException("TODO") |
| Repository | An object that looks like a collection of saved entities: find, save |
| In-memory repository | A repository backed by a HashMap inside the program |
| Vertical slice | One complete path through every layer, working end to end |
| Demo main | A main that runs the main flow end to end and prints the state |
| Driver class | A class that drives the system through scripted scenarios: step(...) |
| Deterministic | Same input, same output, every run |
| Edge case | An unusual input at the limits of the rules: no copy left |
| Extensibility | How easily features can be added |
| Talking point | A prepared sentence about how you'd extend the design |
| Seam / extension point | Where new behaviour plugs in: the BookRepository interface |
| Over-engineering | Structure the problem doesn't need yet |
| Run command | The exact command to build and run: javac -d out ... && java -cp out Main |
Summary
- A machine-coding round turns a product problem into running code in fixed time (often 60-90 minutes of coding; check your own invite).
- Time-box: clarify, design, vertical slice, edge cases, demo.
- Clarify rules and scope; write assumptions; agree the MVP.
- Find entities and relationships; code interfaces first as a compiling skeleton.
- Keep storage in an in-memory repository behind an interface.
- Prove it with a demo main and a driver class; handle edge cases in one place with domain exceptions.
- Prepare extensibility talking points, avoid the common mistakes, and aim at what's scored: requirements, architecture, correctness, testing, judgment.
Next episode: LLD interview follow-ups: adding a feature without breaking code, making it thread-safe, scaling an in-memory design, swapping persistence via repositories, and explaining trade-offs.