| Scale | What Changes? |
|---|---|
| 100 users | Simple class list; few classes identified; manual analysis manageable |
| 10,000 users | More complex requirements; need automated tools to extract classes; more relationships |
| 1 million users | Highly complex domain; classes must support scalability and concurrency; design patterns needed |
| 100 million users | Distributed systems; classes represent microservices; focus on decoupling and scalability |
Identifying classes from requirements in LLD - Scalability & System Analysis
At small scale, the bottleneck is understanding and correctly identifying all relevant classes from requirements. As complexity grows, the bottleneck shifts to managing class dependencies and ensuring classes can scale with user load and data volume.
- Small scale: Use manual analysis and domain expert interviews to identify classes.
- Medium scale: Employ modeling tools (UML) and automated requirement analysis to extract classes.
- Large scale: Apply design patterns (e.g., Factory, Singleton) to manage class creation and dependencies.
- Very large scale: Break system into microservices; each service has its own class model to reduce complexity.
Identifying classes is a design activity, so costs relate to time and effort:
- At 100 users: Few hours to days of analysis.
- At 10,000 users: Weeks of analysis with tooling support.
- At 1 million users: Months of design with iterative refinement.
- At 100 million users: Continuous design evolution with dedicated teams.
Structure your scalability discussion by first explaining how you identify classes from requirements at small scale, then describe challenges as complexity grows, and finally explain how you adapt your approach (tools, patterns, microservices) to handle scale.
Your database handles 1000 QPS. Traffic grows 10x. What do you do first?
Answer: Since the database is the bottleneck, first add read replicas and implement caching to reduce load before redesigning classes or architecture.
Practice
Solution
Step 1: Identify nouns in the requirement
Classes usually come from nouns. Here, 'Book' is a noun representing an object.Step 2: Differentiate between nouns and verbs
'Borrow', 'Return', and 'Search' are actions (verbs), so they are methods, not classes.Final Answer:
Book -> Option CQuick Check:
Class = Noun = Book [OK]
- Choosing verbs as classes
- Confusing actions with objects
- Ignoring nouns in requirements
Solution
Step 1: Understand class syntax in LLD context
Classes are defined with the keyword 'class' followed by the class name.Step 2: Check options for class declaration
class Driver {} uses 'class Driver {}' which is correct syntax for a class.Final Answer:
class Driver {} -> Option AQuick Check:
Class syntax uses 'class' keyword [OK]
- Using function instead of class
- Assigning class name to variable
- Confusing variables with classes
Solution
Step 1: Extract nouns from the requirement
The nouns are Guests, Rooms, and Bookings, which represent objects.Step 2: Match nouns to class names
Classes should be singular nouns representing entities: Guest, Room, Booking.Final Answer:
[Guest, Room, Booking] -> Option BQuick Check:
Classes = Nouns = Guest, Room, Booking [OK]
- Using verbs as classes
- Using plural or combined names incorrectly
- Adding unrelated terms
Solution
Step 1: Identify nouns and verbs
'User' is a noun (class), 'login' and 'logout' are actions (methods).Step 2: Check option correctness
Class: Login; Methods: user(), logout() incorrectly uses 'Login' as a class and 'user()' as a method, which reverses noun and verb roles.Final Answer:
Class: Login; Methods: user(), logout() -> Option DQuick Check:
Class = noun, Method = verb [OK]
- Using verbs as classes
- Naming methods as nouns
- Mixing class and method roles
Solution
Step 1: Identify all nouns in the requirement
Nouns are Customers, Orders, Restaurants, Meals, DeliveryAgents.Step 2: Use nouns as class names and verbs as methods
Classes should be Customer, Order, Restaurant, Meal, DeliveryAgent. Actions like 'place' and 'deliver' become methods.Final Answer:
[Customer, Order, Restaurant, Meal, DeliveryAgent] -> Option AQuick Check:
Classes = Nouns only, verbs become methods [OK]
- Using verbs as classes
- Combining nouns incorrectly
- Omitting important entities
Ready to prove it?
Pass the test and this pattern moves unknown
