Introduction to UML
Unified Modeling Language (UML) is the standard notation for sketching object-oriented designs.
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.
classDiagramclass Vehicle {+String plate+park(spot)}class ParkingSpot {+int id+SpotType type}Vehicle --> ParkingSpot : uses
Step-by-step explanation
- Start class diagram for static structure after requirements.
- Add sequence diagram for one critical use case flow.
- Use activity diagram for branching business processes.
- Use state diagram when object lifecycle has distinct states.
- Label assumptions and unknowns on diagrams.
- 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.
+ publicMethod()- privateField# protectedMethod~ packagePrivateAssociation: Customer ---- OrderComposition: House *-- RoomAggregation: Team o-- PlayerInheritance: Car --|> VehicleImplementation: Service ..|> ServiceInterface
Informative example
UML sketches map directly to Java packages and types:
// Class diagram: Library --1..*--> Book// Sequence: Member -> LibraryService -> Catalog -> Bookpublic 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?
Q2BeginnerWhich UML diagrams matter most in interviews?
Q3IntermediateAssociation vs composition?
Q4IntermediateMust diagrams be perfect?
Q5AdvancedHow much time on UML vs talking?
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.