Naive code → what breaks → clean design.
Don't memorise 23 abstract definitions. Build three real systems sprint by sprint — a Food Delivery app, a Trading Engine and an RPG Game — and fix each pain point with the right pattern in Modern C++23.
Part 1 · 7 pages
class vs struct, private state, class invariants, and const correctness so objects can never enter an invalid state.
virtual methods, override, why a virtual destructor is mandatory on polymorphic bases, and vtable intuition.
Pure virtual classes as contracts, decoupling callers from implementations, and swapping fakes in tests.
Why deep inheritance hierarchies explode when requirements cross-cut, and how assembling small pluggable parts keeps designs flexible.
Who owns what: unique_ptr for exclusive ownership, shared_ptr when lifetime is truly shared, and raw pointers/references as non-owning observers.
Read and draw the 5 UML arrows (implements, inherits, composes, aggregates, depends) and map common code smells directly to SOLID principles.
enum class, concepts vs virtual interfaces, std::variant, std::expected, std::format/std::print, ranges, and std::span.
Part 2 · Story A · 9 chapters
An if/else chain on payment type grows with every new method. Extract a PaymentStrategy interface so new gateways plug in without editing Checkout.
OrderService validates, prices, charges, persists, and sends SMS in one method — every team's change touches the same file.
OrderService hardcodes calls to each notifier. Turn order events into a publish-subscribe bus so listeners attach without touching order logic.
Placed → Accepted → Cooking → PickedUp → Delivered has different cancel and transition rules at every stage, causing status switches in every method.
Callers construct concrete gateways and delivery workflows directly with make_unique, duplicating creation rules across the codebase.
High-level order logic instantiates SqlOrderRepository and RazorpayGateway directly, making unit tests hit the network and database.
CashOnDelivery throws 'not supported' inside refund(), and small cloud kitchens are forced to implement dine-in table booking methods.
A national pizza chain's SDK uses XML payloads and paise integers, which doesn't match our clean MenuProvider interface.
Mobile and web controllers both juggle cart, inventory, pricing, payment, rider dispatch, and notifications in 20 lines of fragile glue.
Part 3 · Story B · 9 chapters
An 8-argument Order constructor leads to swapped parameters and half-built invalid orders. Build validated orders step by step.
Everyone needs one ExchangeConfig and market-data session, but global state leaks between tests. Learn Meyer's Singleton and when DI is better.
A giant validateOrder() function mixes KYC, balance, lot-size, and price-band checks that vary by account tier.
Direct method calls leave no audit trail and no way to roll back a batch of desk orders when a risk limit trips.
Each exchange has its own order router, fee calculator, and symbol mapper — accidentally pairing an NSE router with a BSE fee table corrupts trades.
Traders and desk algorithms holding direct references to each other create a tangled mesh; centralize matching inside an OrderBook mediator.
Every quote lookup hits a slow paid feed and basic users can query Level-2 depth they haven't subscribed to.
TWAP and VWAP copy-paste pre-check, child-order dispatch, and fill reporting, differing only in how they slice quantity.
Callers reach into the order book's internal containers to scan top-N levels or filter institutional fills.
Part 4 · Story C · 8 chapters
Creating ShieldHero, SpeedHero, and ShieldSpeedDoubleDamageHero causes a 2^N subclass explosion.
Separate loops for single items vs bags break as soon as a player puts a potion pouch inside a backpack.
The checkpoint manager reaches into Hero's private HP, mana, and cooldown fields, breaking encapsulation.
Every goblin spawn re-parses loot tables, AI weights, and resistances from config instead of cloning a pre-tuned prototype.
Each tree instance duplicates a 4 MB mesh and texture array in memory instead of sharing intrinsic sprite data.
Combining 5 entity types with 3 graphics APIs creates 15 subclasses; split the abstraction from the renderer implementation.
Adding a new analytics report or save exporter forces edits to Hero, Monster, Trap, and Chest classes.
Ad-hoc string splitting for spell formulas like 'FIRE 20 + 2 * LEVEL' turns into an unmaintainable parser.
Part 5 · 19 interview problems
Log levels (DEBUG/INFO/WARN/ERROR), chained level filters, and pluggable sinks (console, file, memory ring-buffer).
O(1) row/col/diagonal win tracking on an N×N board with pluggable move strategies and clean turn management.
Configurable board entities (snakes, ladders, boost cells), pluggable dice (single, crooked, multi-dice), and multi-player turn loop.
Idle → HasMoney → Dispensing → OutOfStock state machine with coin/note inventory, refund on cancel, and change calculation.
Spot types (Bike, Compact, Large), nearest vs lowest-floor spot allocation strategies, tickets, and hourly/flat fee strategies.
Separate storage from eviction policy so the cache supports O(1) LRU or LFU eviction behind a clean generic interface.
Files and directories as a uniform tree, supporting mkdir, ls, disk-usage calculation, and predicate search filters.
Book titles vs physical barcoded copies, reservations, overdue fine calculation, and hold-queue notifications when a copy returns.
Session state machine (CardInserted → Authenticated → Transacting) paired with a ₹2000 → ₹500 → ₹100 note-dispensing chain.
Route events to Email/SMS/Push channels and wrap senders with retry, rate-limit, and metrics decorators.
Per-client rate limiting with swappable Token Bucket and Sliding Window Log algorithms under concurrent requests.
Validate and split expenses across groups using Equal, Exact, and Percentage strategies, maintain net balances, and settle up.
Elevator car states (Idle, MovingUp, MovingDown), hall/cabin button commands, and LOOK vs nearest-car dispatch strategies.
Stack percentage, flat, and category-cap coupons as price decorators and notify back-in-stock subscribers when inventory replenishes.
Date-range availability, reservation lifecycle (Tentative → Confirmed → CheckedIn → Cancelled), and seasonal/weekend pricing strategies.
Cities, cinemas, shows, and atomic temporary seat holds with TTL expiry so two users can never double-book the same seat.
Topics, append-only message logs, independent per-subscriber offsets, replay from offset, and worker consumption.
Driver matching (nearest vs highest-rated), surge pricing strategies, trip state machine, and live rider/driver status updates.
Per-piece movement rules, board validation, algebraic move history, and reversible Command + Memento snapshots for undo/redo.