System Design
Object-Oriented Design
The 4-Step Framework

A Framework for Object-Oriented Design

When faced with an OOD problem in an interview, jumping straight into code is a common mistake. A structured approach ensures you cover all bases—from ambiguous requirements to clean, modular code.

The 4-Step Framework

This framework provides a repeatable structure to tackle any design problem, ensuring you demonstrate both design thinking and technical proficiency.


Step 1: Clarify the Requirements (5-10 mins)

OOD problems are often intentionally vague. Your goal is to narrow the scope and identify the exact boundaries of the system.

  • Identify Actors: Who or what interacts with the system? (e.g., Guest, Registered Member, System System).
  • Determine Use Cases: What can these actors do? (e.g., "A customer can book a parking spot").
  • Define Constraints: What are the limits? (e.g., "The parking lot has 4 floors, and each floor has 100 spots").
  • Ask "What if" Questions: Handle edge cases early. (e.g., "What happens if the parking lot is full?").

[!NOTE] Focus on the Use Cases first. They will reveal the core functionality your design must support.


Step 2: Define the Core Objects (5-10 mins)

Break down your requirements into "nouns" (objects) and "verbs" (methods). This is the foundation of your class structure.

  • Identify Key Classes: Look for the main entities (e.g., ParkingLot, Vehicle, Ticket).
  • Define Properties: What data does each class hold? (e.g., Vehicle has a licenseNumber).
  • Define Methods: What actions can each class perform? (e.g., ParkingLot can processEntry()).

Relationship Mapping Concept:


Step 3: Map the Relationships (10 mins)

Now, determine how your core objects interact. This is where you decide on inheritance vs. composition.

  • Inheritance ("is-a"): Does one class share common traits with another? (e.g., a Car is a Vehicle).
  • Composition ("has-a"): Does one class contain another? (e.g., a ParkingFloor has many ParkingSpots).
  • Dependency: Does one class use another temporarily? (e.g., a PaymentProcessor uses a BankAPI).
Relationship TypeExampleBest Practice
InheritanceCar → VehicleKeep hierarchy shallow.
CompositionFloor → LotPrefer composition for better flexibility.
AssociationMember → TicketUse when objects just need to "know" each other.

Step 4: Implement the Logic (15-20 mins)

Finally, translate your design into code. Focus on the core logic and use design patterns to handle complexity.

  • Handle State: Use private fields to encapsulate internal state.
  • Implement Patterns:
    • Singleton: For global managers like ParkingLot.
    • Factory: For creating different types of objects (e.g., VehicleFactory).
    • Strategy: For interchangeable logic (e.g., different PaymentMethods).
  • Error Handling: Don't forget to handle invalid inputs or system failures.

Conclusion: Algorithm vs. OOD Interview

FeatureAlgorithm InterviewOOD Interview
Primary GoalEfficiency (Time/Space)Maintainability & Flexibility
FocusHow to solve a problem fast?how to structure a system?
Key ToolsData Structures, RecursionSOLID, Design Patterns, Classes

In the next section, we will apply this framework to a classic problem: Designing a Parking Lot.