Refactoring Monolithic Designs for LLD Interviews
How to break apart a working-but-messy model without changing what it does
☰ Jump to section
Not every LLD prompt starts from a blank canvas. Senior-leaning rounds often hand you a working monolith and ask you to make it maintainable. That is a different sport from Designing Parking Lot from scratch: behavior is sacred; structure is not.
This guide focuses on refactoring for LLD interviews — extracting classes, clarifying seams, and leaving a design that still does the same job.
01The Non-Negotiable Rule: Functional Equivalence
If the system used to support “book seat → pay → email ticket,” your refactored model must still support that path. You may introduce interfaces and collaborators, but you may not quietly drop features to make the diagram pretty.
- List the public use cases before you move boxes.
- Treat that list as a regression suite for your design.
- If you change a behavior, say so — that is a product change, not a refactor.
02Smell → Move Mapping
| Smell in the monolith | Safe first move | Done when |
|---|---|---|
| Giant class | Extract class by responsibility | Each type has one clear job phrase |
| Long method as “god operation” | Extract method / helper type | Orchestrator reads as a short script |
| Duplicated policy logic | Extract strategy / shared policy | One place to change the rule |
| UI + domain mixed | Split presentation from domain | Domain types have no render methods |
| Persistence sprinkled everywhere | Repository / gateway | Domain no longer imports SQL details |
03A Compact Refactoring Script (Interview Pace)
- Read aloud the monolith’s responsibilities (2 minutes).
- Tag smells on the diagram — do not fix yet (2 minutes).
- Pick the highest-leverage cut — usually the biggest SRP breach (1 minute).
- Extract and rewire (10–15 minutes).
- Walk a use case across the new types (3 minutes).
- Stop when the tagged smells are resolved.
Example cut
LibrarySystem handles catalog search, member registration, loan rules, fine calculation, and email reminders. First extract LoanPolicy and NotificationGateway. Leave catalog and members for a second cut if time remains. Two clean seams beat five half-finished ones.
04What Interviewers Listen For
- You preserve behavior deliberately.
- You explain why a boundary exists (“fines change independently of search”).
- You avoid pattern theater.
- You can describe a migration path (facade over old entry point).
LLDCanvas Refactor starts you on monolithic designs with smell tags and asks you to restructure while staying functionally equivalent — the exact constraint these interviews use.
05Worked Sketch: TicketBookingSystem Monolith
Imagine one class that searches shows, holds seats, charges cards, emails tickets, and applies promo codes. Under a behavior lock, a strong first cut looks like:
TicketBookingFacade // keeps old entry API stable
CatalogService // search shows
SeatHoldService // reservations + expiry
PaymentGateway (port)
PricingPolicy (port) // promos / base fare
TicketNotifier (port)
// External behavior unchanged:
book(showId, seatIds, userId, promo?)You did not redesign the product. You gave each reason-to-change a home and left a facade so callers do not break mid-interview. That is the refactoring story interviewers want to hear.
- If time remains, extract
PromoCoderules from a genericPricingPolicy. - If time is gone, stop — a clear facade + three ports already beats a half-migrated mess.
06Refactor vs Debug-and-Fix vs OCP Drills
Refactor assumes a working mess and equivalence. Debug & Fix centers on resolving specific violations against a target clean design. Change-one-requirement drills stress OCP when a new need arrives mid-design. Use each for the skill it trains; see also open-closed principle under requirement changes.
07Key Takeaways
- Refactoring interviews grade structure under a behavior lock.
- Tag smells first; extract the highest-leverage seam second.
- Walk use cases after every major cut.
- Stop at clarity — not perfection.
Practice on authored monoliths in Refactor and keep a side journal of which smells you still miss under time.
Frequently Asked Questions
AYou receive a working design (often “legacy”) and must improve structure without changing external behavior. Interviewers score smell recognition and clean extractions.
LLDCanvas Team
Engineering at LLDCanvas
Ready to practice?
Turn reading into results
110+ LLD interview questions, a live canvas, and timed Interview Mode.
Reader’s Notes (0)
Sign in to join the discussion
Sign inLoading notes…