Bird
Raised Fist0
LLDsystem_design~25 mins

Identifying classes from requirements in LLD - System Design Exercise

Choose your learning style10 modes available
Design: Class Identification from Requirements
Focus on identifying classes, their attributes, methods, and relationships from textual requirements. Out of scope: detailed implementation or database design.
Functional Requirements
FR1: Analyze given software requirements to find key entities.
FR2: Determine attributes and behaviors for each entity.
FR3: Establish relationships between entities.
FR4: Create a clear class diagram representing the system structure.
Non-Functional Requirements
NFR1: Classes must represent real-world concepts or system components.
NFR2: Relationships must be accurate (inheritance, association, aggregation, composition).
NFR3: Design should be simple and understandable for beginners.
NFR4: Support scalability for future system expansion.
Think Before You Design
Questions to Ask
❓ Question 1
❓ Question 2
❓ Question 3
❓ Question 4
❓ Question 5
Key Components
Entities as classes
Attributes as class properties
Methods as class behaviors
Relationships like inheritance and associations
Design Patterns
Single Responsibility Principle
Encapsulation
Inheritance and Polymorphism
Association, Aggregation, Composition
Reference Architecture
Requirements Text
      |
      v
  Identify Nouns (Entities) ---> Define Classes
      |                             |
      v                             v
  Identify Verbs (Behaviors)    Define Attributes
      |                             |
      v                             v
  Establish Relationships <-------
      |
      v
  Draw Class Diagram
Components
Class
UML/OO Design
Represents an entity with attributes and behaviors.
Attribute
UML/OO Design
Describes properties or data held by a class.
Method
UML/OO Design
Defines actions or behaviors of a class.
Relationship
UML/OO Design
Shows how classes connect (inheritance, association, etc.).
Request Flow
1. Read the software requirements text.
2. Extract nouns to identify potential classes.
3. Extract verbs to identify methods or behaviors.
4. Determine attributes from descriptive phrases.
5. Analyze relationships between classes (e.g., 'is a', 'has a').
6. Create a class diagram showing classes, attributes, methods, and relationships.
Database Schema
Not applicable; focus is on class identification and relationships, not database design.
Scaling Discussion
Bottlenecks
Complex requirements with many entities can cause confusion.
Ambiguous or incomplete requirements lead to incorrect class identification.
Overlapping responsibilities among classes reduce clarity.
Ignoring relationships can cause poor system structure.
Solutions
Break down requirements into smaller parts and analyze separately.
Clarify ambiguous requirements with stakeholders.
Apply design principles like Single Responsibility Principle.
Use iterative refinement and peer reviews of class diagrams.
Interview Tips
Time: Spend 10 minutes understanding requirements and identifying nouns and verbs, 15 minutes defining classes and relationships, and 5 minutes reviewing and explaining the class diagram.
Explain how you identify classes from nouns in requirements.
Describe how verbs help define class behaviors (methods).
Discuss how you determine relationships between classes.
Mention design principles used to keep classes focused and maintainable.
Highlight importance of iterative refinement and communication.

Practice

(1/5)
1. Which of the following is most likely a class when designing a library management system?
easy
A. Return
B. Borrow
C. Book
D. Search

Solution

  1. Step 1: Identify nouns in the requirement

    Classes usually come from nouns. Here, 'Book' is a noun representing an object.
  2. Step 2: Differentiate between nouns and verbs

    'Borrow', 'Return', and 'Search' are actions (verbs), so they are methods, not classes.
  3. Final Answer:

    Book -> Option C
  4. Quick Check:

    Class = Noun = Book [OK]
Hint: Pick the noun as class, verbs become methods [OK]
Common Mistakes:
  • Choosing verbs as classes
  • Confusing actions with objects
  • Ignoring nouns in requirements
2. In a ride-sharing app, which of these is the correct way to represent a class in code?
easy
A. class Driver {}
B. function Driver() {}
C. var Driver = 5;
D. let driver = 'John';

Solution

  1. Step 1: Understand class syntax in LLD context

    Classes are defined with the keyword 'class' followed by the class name.
  2. Step 2: Check options for class declaration

    class Driver {} uses 'class Driver {}' which is correct syntax for a class.
  3. Final Answer:

    class Driver {} -> Option A
  4. Quick Check:

    Class syntax uses 'class' keyword [OK]
Hint: Look for 'class' keyword to identify class declaration [OK]
Common Mistakes:
  • Using function instead of class
  • Assigning class name to variable
  • Confusing variables with classes
3. Given the requirement: "A hotel booking system must manage Guests, Rooms, and Bookings." Which of these is the correct set of classes identified?
medium
A. [Booking, Book, GuestList]
B. [Guest, Room, Booking]
C. [Guest, Book, RoomBooking]
D. [Room, Guest, ReservationList]

Solution

  1. Step 1: Extract nouns from the requirement

    The nouns are Guests, Rooms, and Bookings, which represent objects.
  2. Step 2: Match nouns to class names

    Classes should be singular nouns representing entities: Guest, Room, Booking.
  3. Final Answer:

    [Guest, Room, Booking] -> Option B
  4. Quick Check:

    Classes = Nouns = Guest, Room, Booking [OK]
Hint: Pick singular nouns as class names from requirements [OK]
Common Mistakes:
  • Using verbs as classes
  • Using plural or combined names incorrectly
  • Adding unrelated terms
4. You have a requirement: "The system should allow Users to login and logout." Which of the following is an error in identifying classes and methods?
medium
A. Class: User; Methods: login(), logout()
B. Class: UserAccount; Methods: login(), logout()
C. Class: User; Methods: authenticate(), logout()
D. Class: Login; Methods: user(), logout()

Solution

  1. Step 1: Identify nouns and verbs

    'User' is a noun (class), 'login' and 'logout' are actions (methods).
  2. 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.
  3. Final Answer:

    Class: Login; Methods: user(), logout() -> Option D
  4. Quick Check:

    Class = noun, Method = verb [OK]
Hint: Classes are nouns; methods are verbs [OK]
Common Mistakes:
  • Using verbs as classes
  • Naming methods as nouns
  • Mixing class and method roles
5. A food delivery app requirement states: "Customers place Orders, Restaurants prepare Meals, and DeliveryAgents deliver Orders." Which classes should be created to model this system correctly?
hard
A. [Customer, Order, Restaurant, Meal, DeliveryAgent]
B. [Customer, PlaceOrder, Restaurant, Meal, Deliver]
C. [CustomerOrder, RestaurantMeal, Delivery]
D. [Order, Meal, DeliveryAgent, Place]

Solution

  1. Step 1: Identify all nouns in the requirement

    Nouns are Customers, Orders, Restaurants, Meals, DeliveryAgents.
  2. 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.
  3. Final Answer:

    [Customer, Order, Restaurant, Meal, DeliveryAgent] -> Option A
  4. Quick Check:

    Classes = Nouns only, verbs become methods [OK]
Hint: Classes = nouns; actions = methods in those classes [OK]
Common Mistakes:
  • Using verbs as classes
  • Combining nouns incorrectly
  • Omitting important entities
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard