Low-Level Design Tutorial 0/42 lessons ~6 min read Lesson 16

    Introduction to UML

    Unified Modeling Language (UML) is the standard notation for sketching object-oriented designs.

    Course progress0%
    Focus
    10 guided sections
    Practice signal
    Examples included
    Career prep
    Interview Q&A included

    Introduction

    Unified Modeling Language (UML) is the standard notation for sketching object-oriented designs. In LLD interviews you rarely need every diagram type — class, sequence, activity, and state diagrams cover ninety percent of whiteboard sessions.

    UML is communication, not bureaucracy. Boxes and arrows help interviewers follow your thinking faster than verbal description alone. TechLearningPRO uses text-based UML and Mermaid equivalents you can reproduce quickly.

    This lesson orients you to diagram types, when to use each, and interview pacing.

    Understanding the topic

    Key concepts

    • Structural diagrams: class, component, deployment (LLD focuses on class).
    • Behavioral diagrams: sequence, activity, state, use case.
    • Notation: visibility (+ public, - private), multiplicity (1, *, 0..1).
    • Associations, aggregations, compositions — ownership semantics.
    • Diagrams are sketches — incomplete is OK if labeled.
    • Mermaid and PlantUML are interview-friendly text UML tools.
    text
    classDiagram
    class Vehicle {
    +String plate
    +park(spot)
    }
    class ParkingSpot {
    +int id
    +SpotType type
    }
    Vehicle --> ParkingSpot : uses

    Step-by-step explanation

    1. Start class diagram for static structure after requirements.
    2. Add sequence diagram for one critical use case flow.
    3. Use activity diagram for branching business processes.
    4. Use state diagram when object lifecycle has distinct states.
    5. Label assumptions and unknowns on diagrams.
    6. Sync verbal explanation with what you draw.

    Syntax reference

    Common UML visibility and relationship symbols:

    • +/-/#/~ map to Java access modifiers.
    • Composition: strong ownership — Room dies with House.
    • Aggregation: weaker whole-part — Team may exist without Player.
    text
    + publicMethod()
    - privateField
    # protectedMethod
    ~ packagePrivate
    Association: Customer ---- Order
    Composition: House *-- Room
    Aggregation: Team o-- Player
    Inheritance: Car --|> Vehicle
    Implementation: Service ..|> ServiceInterface

    Informative example

    UML sketches map directly to Java packages and types:

    java
    // Class diagram: Library --1..*--> Book
    // Sequence: Member -> LibraryService -> Catalog -> Book
    public final class LibraryService {
    private final Catalog catalog;
    public LibraryService(Catalog catalog) {
    this.catalog = catalog;
    }
    public Loan checkout(String memberId, String isbn) {
    Book book = catalog.findAvailable(isbn)
    .orElseThrow(() -> new NotFoundException(isbn));
    book.markLoaned();
    return new Loan(memberId, isbn, Instant.now());
    }
    }

    Draw LibraryService, Catalog, Book first — then code mirrors the diagram for interviewer alignment.

    Real-world use

    Real-world applications

    • Whiteboard LLD at Amazon, Google, Microsoft.
    • RFC diagrams before implementation sprints.
    • Onboarding developers to module structure.

    Best practices

    • Draw only diagrams that clarify the current discussion.
    • Keep class diagrams to 8–12 classes in interviews.
    • Number sequence diagram steps for easy reference.
    • Use consistent naming matching Java types.
    • Erasing and simplifying beats overcrowding.

    Common mistakes

    • Every UML diagram type on one page.
    • Deployment diagram when asked for in-process LLD.
    • Missing multiplicities on associations.
    • Diagram/code name mismatch confusing interviewer.

    Advanced interview questions

    Q1BeginnerWhat is UML used for in LLD?
    Visual language for classes, interactions, workflows, and state — faster communication than code alone.
    Q2BeginnerWhich UML diagrams matter most in interviews?
    Class and sequence diagrams; activity and state as needed.
    Q3IntermediateAssociation vs composition?
    Composition implies lifecycle ownership; association is a general link.
    Q4IntermediateMust diagrams be perfect?
    No — sketches with clear labels beat ornate incomplete diagrams.
    Q5AdvancedHow much time on UML vs talking?
    Draw core structure in 10 minutes while narrating; deepen one sequence flow.

    Summary

    UML communicates OO structure and behavior quickly. Class + sequence diagrams are interview staples. Match diagram names to Java types. Use Mermaid/text UML for speed. Sketches beat exhaustive formal models in timed rounds.

    Ready to mark this lesson complete?Track your journey across the entire course.