Your country

Tools that support it use your country for local currency, number formats, units and paper size. Your choice is saved only in this browser.

Type a name or a two-letter code. Use the up and down arrow keys to move through the countries, Enter to choose one and Escape to close.

Low-Level Design (Object-Oriented Design) Module 8

Code quality under time pressure interview questions

Interview questions on code quality under time pressure: warm-ups, then what each harder question tests and how a good answer starts.

8 questions: 3 warm-ups and 5 with model answers · Levels: Fresher to senior

Warm-up questions

Short questions with short answers, each answered in full.

  1. Fresher

    What is primitive obsession? Give an example from a low-level design answer.

    Answered in the lesson Code smells interviewers flag in LLD answers

  2. Fresher

    Why do interviewers dislike class names such as ParkingManager or BookingHelper?

    Answered in the lesson Code smells interviewers flag in LLD answers

  3. Fresher to mid

    What is the difference between over-engineering and under-modelling in a low-level design answer?

    Answered in the lesson Weak LLD answers: how to spot and fix them

Questions with model answers

What each question tests, the first step of a good answer and the follow-ups to expect.

  1. Mid to senior

    Fifteen minutes are left in a 60-minute machine-coding round. Your ParkingLotService is about 300 lines long, keeps statuses as strings and repeats an if-chain on the vehicle type in three methods. What do you change now, what do you leave, and what do you tell the interviewer?

    What it tests
    Ranking refactorings by risk and by the follow-up most likely to come, keeping the program working after every change, and stating the remaining trade-offs plainly.
    First step
    Before touching anything, make sure one check runs in seconds: the tests, or a golden scenario if there are none. Then rank the smells by what a likely follow-up would hit. A new vehicle type hits the three if-chains and a new status hits the strings, so those two go first, in small steps, and the rest is said rather than done.
    Follow-ups

    From the lesson Code smells interviewers flag in LLD answers

    Model answer, Pro. Model answers open with any pass; prices are in the notice on this page.

    Opening the model answers with your pass…

    Model answers open with any MySmartCoPilot pass.

    • Pro pass · 1 week₹79$2.99
    • 30 days₹179$5.99
    • 1 year₹1,699$45

    One payment; a pass never renews. The price shown is the total you pay: no fees or charges are added at checkout.

    It also opens every other in-depth part in Learn and every Pro tool. Sales are final, except where the law gives you a right to withdraw, for example in the EU and the UK (refund policy).

    In the answer:

    • Model answer
    • Follow-up answers
    • Common mistakes
    • Rubric
    • Variants
    • about 3 minutes
  2. Mid to senior

    An interviewer points at your FeeCalculator: each of its methods reads four or five fields of a Ticket, and Ticket has no methods of its own. Is that feature envy, or a sound strategy? Say what you would move into Ticket and what you would keep separate.

    What it tests
    Telling feature envy from a deliberate strategy, putting behaviour next to the data it uses, and keeping rules that change for different reasons apart.
    First step
    List what each method reads and why it would change. Working out how long a car stayed, or whether a ticket is paid, uses only the ticket's own data, so it moves into Ticket. Pricing a stay changes when the operator changes tariffs, a different reason, so a fee policy that receives the duration and the vehicle kind can stay separate.
    Follow-ups

    From the lesson Code smells interviewers flag in LLD answers

    Model answer, Pro.

    In the answer:

    • Model answer
    • Follow-up answers
    • Common mistakes
    • Rubric
    • Variants
    • about 3 minutes
  3. Mid to senior

    Your elevator answer has an interface for every class, three factories, a command class for each input word and a Singleton for the system. The interviewer says it feels heavy. What do you remove first, what do you keep, and how do you justify each choice?

    What it tests
    Telling structure that serves a stated need from structure added for its own sake, removing it in safe steps, and defending what stays.
    First step
    Ask what problem each piece solves in this prompt. The Singleton solves none and makes tests share state, so it goes first: build the system in one place and pass it on. Interfaces with one implementation and factories that only call a constructor decide nothing either. Keep the dispatch rule in one place, the one spot where a second policy is plausible.
    Follow-ups

    From the lesson Weak LLD answers: how to spot and fix them

    Model answer, Pro.

    In the answer:

    • Model answer
    • Follow-up answers
    • Common mistakes
    • Rubric
    • Variants
    • about 3 minutes
  4. Mid to senior

    Each test of your elevator answer passes when it runs alone, but two fail when the whole suite runs, and which two depends on the order. What do you look for, and how do you change the design so that it cannot happen again?

    What it tests
    Diagnosing order-dependent tests, finding state that outlives a test, and removing it from the design instead of patching the tests.
    First step
    Run the failing pair in both orders: a test that passes alone and fails after another inherits state from it. List what outlives one test: singletons, class attributes, module-level collections, caches and clocks. Then move the creation of that state to one place, such as main(), and pass it to the objects that need it, so each test builds its own.
    Follow-ups

    From the lesson Weak LLD answers: how to spot and fix them

    Model answer, Pro.

    In the answer:

    • Model answer
    • Follow-up answers
    • Common mistakes
    • Rubric
    • Variants
    • about 3 minutes
  5. Fresher to senior

    Halfway through a 60-minute round, the interviewer asks what your parking-lot answer does when a ticket is lost, a card payment is declined at the exit, or the same ticket is scanned twice. It handles none of them. Which do you design now, which do you only describe, and how?

    What it tests
    Ranking failure paths by harm and likelihood, turning the important ones into states, refusals or idempotent operations, and stating the rest as explicit assumptions.
    First step
    Sort the failure paths by what goes wrong if they are ignored: money lost, a car stuck at the barrier, a count that drifts. A duplicate scan is common and cheap to make harmless, so make the exit idempotent now. A lost ticket needs a rule from the business, so ask for it and record the answer as an assumption.
    Follow-ups

    From the lesson Weak LLD answers: how to spot and fix them

    Model answer, Pro.

    In the answer:

    • Model answer
    • Follow-up answers
    • Common mistakes
    • Rubric
    • Variants
    • about 3 minutes

All Low-Level Design (Object-Oriented Design) interview questions · The Low-Level Design (Object-Oriented Design) track

Quick answers and tool search

Type to search tools or to get a quick answer, for example 18% of 2500. Use the up and down arrow keys to move through the results, Enter to choose, and Escape to close.