CMD Guide
HomeOO & Low-Level DesignOOD Foundations

OO Analysis and Design

OO Analysis and Design

Before you write a single class, you face a harder problem than coding: deciding what classes should even exist. Object-Oriented Analysis and Design (OOAD) is the disciplined bridge from a fuzzy problem statement ("build a ride-sharing dispatcher") to a set of collaborating objects that model that problem faithfully. It exists because the naive alternative—jumping straight to code driven by the database schema or by whatever screen you're building—produces designs that fight the domain. When requirements shift (and they always do), a domain-faithful model bends; a schema-driven or procedure-driven one snaps.

The core insight of OOAD is that a good software structure mirrors the structure of the problem. If the real world has Riders, Drivers, and Trips that relate in specific ways, your objects should too. Then a change in one real-world concept touches exactly one place in code. This is why interviewers open low-level design rounds with "design a parking lot" rather than "write a linked list"—they're testing whether you can extract structure from ambiguity.

How it works: analysis then design

OOAD splits into two phases with a deliberate wall between them.

The wall matters: analysis in domain terms keeps you from prematurely baking in a data structure or framework. You defer the question "HashMap or database?" until design, so it doesn't contaminate your understanding of the domain. Two guiding principles run through both phases: assign each responsibility to the object that owns the relevant data (GRASP Information Expert), and model relationships to reflect real lifecycles (a Trip composes its Route; it merely associates with a Driver).

A concrete example

Consider the requirement: "A rider requests a trip; the system assigns an available driver and tracks the trip's status." Noun extraction gives Rider, Trip, Driver, and a coordinator Dispatcher. Verbs (request, assign) become behaviors. Applying Information Expert, the Trip owns its own status transitions; the Dispatcher owns the matching logic because only it sees the pool of drivers.

// Analysis found the concepts; design assigns responsibilities.
enum TripStatus { REQUESTED, ASSIGNED, COMPLETED, CANCELLED }

class Trip {
    private final Rider rider;
    private Driver driver;              // association: set later
    private TripStatus status = TripStatus.REQUESTED;

    Trip(Rider rider) { this.rider = rider; }

    // Information Expert: Trip owns its own state transition.
    void assignTo(Driver d) {
        if (status != TripStatus.REQUESTED)
            throw new IllegalStateException("already handled");
        this.driver = d;
        this.status = TripStatus.ASSIGNED;
    }
}

class Dispatcher {                     // Controller: coordinates the use case
    private final List<Driver> pool;
    Dispatcher(List<Driver> pool) { this.pool = pool; }

    Trip request(Rider rider) {
        Trip trip = new Trip(rider);
        Driver free = pool.stream()
            .filter(Driver::isAvailable)
            .findFirst()
            .orElseThrow(() -> new IllegalStateException("no drivers"));
        trip.assignTo(free);
        return trip;
    }
}

This applies when the problem has a rich domain with meaningful entities and rules—dispatchers, parking lots, elevators, vending machines. Notice the design choices: Trip guards its own invariant (you cannot assign an already-assigned trip), and Dispatcher is a thin coordinator, not a god object holding all logic.

When to use it, and when not

OOAD earns its cost when the domain is behavior-rich and long-lived: complex business rules, evolving requirements, multiple actors. There, the modeling discipline pays back many times over.

The judgment: OOAD is not free. Over-modeling a trivial problem (a ParkingLotFactoryStrategyManager for a 10-line script) is a real failure mode. Match modeling investment to domain complexity.

Signal in the problemOOADTransaction script / functional
Behavior-rich domain with evolving rules✅ pays back⚠️ logic scatters
Few rules, mostly CRUD⚠️ ceremony✅ faster
Multiple actors and a stateful lifecycle✅ objects guard invariants⚠️ invariants leak
Data-transformation pipeline⚠️ mutable-object friction✅ pure functions fit
Sequence diagram: rider requests a trip, Dispatcher checks Driver availability, creates Trip, assigns driver, returns trip
Sequence diagram: rider requests a trip, Dispatcher checks Driver availability, creates Trip, assigns driver, returns trip

The same request as a sequence diagram

The class diagram shows the static structure; the sequence diagram shows the dynamic collaboration for one use case. Follow the message arrows top-to-bottom to see who owns each decision.

This is the payoff of Information Expert: the Dispatcher does not reach into the Trip's internals to flip a status flag; it sends a message and lets the Trip enforce its own contract. If the matching rules change, only the Dispatcher changes; if the status lifecycle changes, only the Trip changes.

Pitfalls interviewers probe

Key takeaways

🤖 Don't fully get this? Learn it with Claude

Stuck on OO Analysis and Design? Open Claude, copy a block below, and it'll teach you this exact concept — visually and interactively.

🎨 Explain it visually

Build the mental picture, not memorization.

I just read a lesson on **OO Analysis and Design** (OO & Low-Level Design) and want to truly understand it. Explain OO Analysis and Design from first principles using ONE vivid real-world analogy and a visual mental model — draw it as ASCII art or a clear step-by-step diagram — with a concrete example using real numbers. Then ask me one question to check I got the mental picture, and wait for my reply. If you're unsure or a claim isn't standard, say so and reason from first principles instead of guessing.
🤔 Walk me through it (interactive)

Socratic — adapts to where you're stuck.

Teach me **OO Analysis and Design** interactively. Ask me ONE guiding question at a time, wait for my answer, and adapt to my confusion — build the idea with me step by step instead of explaining it all at once. If you're unsure or a claim isn't standard, say so and reason from first principles instead of guessing.
🧪 Quiz me & fix my gaps

Active recall exposes what you missed.

Quiz me on **OO Analysis and Design** with 5 questions, easy to tricky, ONE at a time. Tell me if each answer is right; at the end, explain clearly what I got wrong and why. If you're unsure or a claim isn't standard, say so and reason from first principles instead of guessing.
🧠 Make it stick

Intuition + hook + flashcards for long-term memory.

Help me remember **OO Analysis and Design** for the long term: give the one-sentence intuition, a memorable hook/mnemonic, a tiny worked example, and 3 active-recall flashcards (Q -> A). If you're unsure or a claim isn't standard, say so and reason from first principles instead of guessing.

📝 My notes