Topic 3.2
Identify Entities
In one line
Nouns become entities, verbs become operations, rules become business logic. A disciplined translation from English to classes.
Think of it like this
Reading a story and underlining the characters (nouns) and what they do (verbs). The characters become your classes, and what they do becomes your methods.
Key ideas
- 01
Nouns → entities: 'ParkingSpot', 'Gate', 'Ticket', 'Vehicle', 'Floor'.
- 02
Verbs → operations: 'assign spot', 'generate ticket', 'calculate fee', 'release spot'.
- 03
Rules → business logic: 'free first 30 min', 'bike can't use truck spot', 'one ticket per plate in lot'.
- 04
Underline every noun in the prompt; ask which are real objects vs attributes (plate is an attribute, not an entity).
- 05
Each entity gets an identity (id), state (fields), and behavior (methods) — not just getters/setters.
- 06
Anemic domain model (pure getters) is an interview red flag; behavior should live next to the data it needs.
Java / Spring map
- →
Mapper: prompt noun → JPA @Entity or record; verb → service method or domain method.
Code & diagrams
Worked example: turning a one-paragraph prompt into classes and methods.
PROMPT
"A LIBRARY has BOOKS. A MEMBER can BORROW up to 5 books for 14 days.
Late RETURNS pay a FINE of ₹10/day. Members can RESERVE a book
that is currently borrowed and get NOTIFIED when it's back."
NOUNS → candidate classes
Library, Book, Member, Loan (borrowing record), Fine, Reservation
"title", "due date", "₹10/day" → ATTRIBUTES, not classes
Book vs BookCopy! The library may own 3 copies of the same title.
→ Book (title, author, ISBN) 1 ──── N BookCopy (barcode, status)
This split is the #1 thing interviewers look for here.
VERBS → methods (and who owns them)
borrow(member, copy) → LibraryService (touches Member + Copy + Loan)
return(copy) → LibraryService, which asks Loan to computeFine()
computeFine() → Loan (it knows its own due date) ← tell, don't ask
reserve(member, book) → ReservationService
notify(member) → Notifier interface (email / SMS / push)
RULES → where they are enforced
"max 5 books" → Member.canBorrow()
"14 days" → LoanPolicy (a Strategy: students 14d, staff 30d)
"₹10/day" → FinePolicy (a Strategy)Explain without notes
From 'ride booking' prompt, list 8 entities and justify each.
Practice
Entity-extraction drill on 5 random problems from the Phase 4 list.
Completion checklist
I can extract entities/verbs/rules from any prompt in minutes.