Design Principles Course
Staff-engineer design principles — clean architecture, distributed systems, reviews, and refactoring mastery.
Enterprise learning path
Foundations
- 1Design Principles HomeNext up
Welcome to Design Principles: From Clean Code to Staff Engineering Excellence — an internal academy for engineers who need maintainable systems, principled code reviews, archite…
- 2What Are Design Principles?
Design principles are durable guidelines for structuring code and systems — they describe forces and trade-offs (cohesion, coupling, change isolation) rather than specific reusa…
- 3Principles vs Patterns
Principles state enduring forces; patterns are named, reusable solutions to recurring problems.
- 4Principles vs Rules
Rules are enforceable constraints (lint, CI, style guides).
- 5When Principles Matter
Principles matter most when change cost exceeds abstraction cost — typically after the second use case, when multiple teams touch the same module, or when incidents correlate wi…
- 6Code Quality Mindset
Code quality is a business investment — not aesthetics.
- 7Design Principles Myths
Common myths — "SOLID always," "more interfaces = better," "DRY means no duplicate lines" — cause over-engineering.
SOLID Principles
- 8SOLID Overview
SOLID — five principles from Robert C.
- 9Single Responsibility Principle
SRP — a module should have one reason to change: one actor or axis of change drives modifications, not "one method only" literalism.
- 10Open/Closed Principle
OCP — software entities should be open for extension (new behavior) but closed for modification (existing tested code stays stable).
- 11Liskov Substitution Principle
LSP — subtypes must be substitutable for their base types without breaking client expectations.
- 12Interface Segregation Principle
ISP — clients should not depend on methods they don't use.
- 13Dependency Inversion Principle
DIP — high-level modules should not depend on low-level details; both depend on abstractions.
- 14SOLID in Practice
SOLID in practice means applying letters together with trade-offs — not maximizing interfaces.
Classic Principles
- 15DRY Principle
DRY (Don't Repeat Yourself) — every piece of knowledge should have a single, authoritative representation.
- 16KISS Principle
KISS — prefer the simplest design that meets requirements.
- 17YAGNI Principle
YAGNI — don't build capability for hypothetical futures.
- 18Separation of Concerns
SoC — distinct sections of a program should address distinct concerns with minimal overlap.
- 19Law of Demeter
LoD — a module should not know the internal details of objects it manipulates.
- 20Composition Over Inheritance
Favor composing behaviors over deep inheritance trees — avoids fragile base class and LSP violations.
- 21Program to Interface
Depend on abstractions (interfaces, protocols) not concrete classes — enables substitution and testing.
- 22Principle of Least Astonishment
Code should behave as readers expect — surprise causes bugs and review friction.
Quality & Maintainability
- 23High Cohesion, Low Coupling
High cohesion, low coupling — modules do related work together and depend minimally through stable interfaces.
- 24Immutability Principle
Prefer immutable data structures where practical — reduces shared mutable state bugs and simplifies reasoning in concurrent systems.
- 25Fail Fast
Detect and report errors at the earliest point — don't propagate invalid state.
- 26Defensive Programming
Validate inputs and invariants at boundaries — balance with fail-fast clarity, not silent swallowing.
- 27Tell, Don't Ask
Tell objects what to do rather than querying state and deciding externally — keeps behavior encapsulated.
- 28Information Hiding
Hide implementation details behind stable interfaces — Parnas's foundational idea behind encapsulation.
- 29Encapsulation Deep Dive
Encapsulation bundles data and behavior, controlling access — not merely private fields.
- 30Pure Functions & Side Effects
Pure functions same output for same input, no side effects — easier to test and parallelize.
Architecture Principles
- 31Stable Dependencies
Depend in the direction of stability — volatile modules depend on stable ones, not vice versa.
- 32Acyclic Dependencies
Package dependency graph must be acyclic — cycles prevent build ordering and clear ownership.
- 33Common Closure Principle
Classes that change together should be packaged together — reduces release friction.
- 34Common Reuse Principle
Don't force clients to depend on things they don't use — package granularity matters.
- 35Stable Abstractions Principle
Abstractions should be more stable than implementations they abstract.
- 36Orthogonality
Orthogonal components change independently — change in one does not affect others (Pragmatic Programmer).
- 37Locality of Behavior
LoB — behavior should live near the code it relates to; balance with DRY at the right level.
- 38Dependency Management Principles
Managing third-party and internal dependencies — semver, pinning, and abstraction at boundaries.
Application & Interview
- 39Applying Principles Daily
Daily application — principles in every PR, standup refactor note, and tech debt ticket — not a quarterly architecture initiative.
- 40Principles in Code Review
Principled code review — comment with smell + principle + suggested refactor — never vague "clean this up."
- 41Principles in Legacy Code
Legacy code (Feathers: code without tests) — apply principles incrementally with characterization tests and seams.
- 42Capstone: Principles Refactor
Capstone — refactor UserAccountFacade (900 lines, 12 responsibilities) with SRP, DIP, OCP, DRY incrementally.
- 43Design Principles Interview Framework
Interview framework — read code, name violations, propose minimal refactor, state trade-offs, connect to tests — in 35 minutes.
- 44Mock: SOLID Code Review
Mock SOLID review — practice reviewing a realistic PR with SRP, OCP, LSP, ISP, DIP violations.
- 45Mock: Principle Trade-offs
Trade-off mock — when SOLID conflicts with KISS/YAGNI, articulate the decision framework.
- 46Design Principles Cheat Sheet
Cheat sheet — quick reference for reviews and interviews.
Design Principles in Distributed Systems
- 47Idempotency Principles
Idempotent handlers produce the same outcome when executed multiple times — essential for at-least-once delivery in distributed systems.
- 48Eventual Consistency Boundaries
Accept eventual consistency only at explicit boundaries with compensating actions and clear user-facing semantics.
- 49Saga Orchestration Principles
Long-running distributed transactions use sagas — orchestrated or choreographed steps with compensating transactions.
- 50Event-Driven Separation
Publish domain events at bounded context boundaries — consumers depend on event contracts, not internal models.
- 51API Contract Principles
Stable API contracts — versioning, backward compatibility, and consumer-driven contracts at service boundaries.
- 52Circuit Breaker Resilience
Fail fast when dependencies are unhealthy — bulkheads and circuit breakers prevent cascade (Release It!, Nygard).
- 53CAP Theorem in Practice
CAP — partition tolerance is mandatory; choose consistency vs availability per use case, not globally.
- 54Microservice Decomposition
Decompose by bounded context and change isolation — not by technical layer alone.
Real Enterprise Case Studies
- 55Stripe API Design
Stripe API design embodies ISP, idempotency, and stable abstractions — developer experience as architecture principle.
- 56Netflix Engineering Culture
Netflix — freedom and responsibility — principles in microservices, chaos engineering, and paved-road platforms.
- 57Google Readability
Google readability — principle-based review culture scaling to millions of LOC across languages.
- 58Amazon Operating Model
Amazon — two-pizza teams, service-oriented architecture, and working backwards from PR/FAQ — organizational principles driving technical boundaries.
- 59Spotify Squad Model
Spotify squads — autonomy with alignment — principles for squad boundaries, guilds, and shared infrastructure.
Architecture Reviews
- 60Architecture Review Process
Formal architecture review — who attends, artifacts required, outcomes, and escalation paths.
- 61Review Readiness Checklist
Come prepared: context, options considered, trade-offs, SLO impact, rollback — not slide-deck theater.
- 62ADR Writing Mastery
Architecture Decision Records — context, decision, consequences, status — Michael Nygard format.
- 63Design Review Facilitation
Staff engineers facilitate — draw out dissent, timebox, ensure decision owner, capture action items.
- 64Principle-Based Rubrics
Score designs against principles: coupling, testability, operability — not checklist patterns.
- 65Architecture Review Anti-Patterns
Reviews that fail: no decision owner, bikeshedding, architecture astronautics, missing rollback.
Legacy Modernization
- 66Strangler Fig Pattern
Gradually replace legacy by routing traffic to new system at seams — Fowler's strangler fig.
- 67Characterization Testing
Tests that capture current behavior before refactor — Feathers' legacy code lifeline.
- 68Seam Identification
Find points where behavior can change without editing call sites — object seam, preprocessing seam.
- 69Incremental Extraction
Extract one responsibility per PR — trunk-based development with principles.
- 70Legacy DIP Migration
Introduce interfaces at boundaries already touched by changes — don't boil the ocean.
- 71Monolith Decomposition
Decompose by bounded context and business capability — identify natural seams.
- 72Migration Rollback Strategy
Every migration slice needs rollback — feature flags, dual-write parity, reconciliation jobs.
Design Principles in System Design
- 73URL Shortener Principles
System design through principles — hashing, collision handling, redirect SLO, cache layers.
- 74Rate Limiter Principles
Token bucket vs sliding window — SRP for limit policy vs storage; fail-fast at edge.
- 75Notification System Principles
At-least-once delivery, idempotent consumers, ISP for email/SMS/push channels.
- 76Feed System Principles
Fan-out on write vs read — trade-off documentation in ADR; eventual consistency at feed boundary.
- 77Payment System Principles
Strong consistency for ledger, idempotency, audit trail — immutability and append-only events.
- 78Chat System Principles
Ordering, delivery guarantees, presence — separate concerns (SoC) for message vs presence vs history.
- 79Search System Principles
Inverted index separation, eventual indexing, DIP between query parser and retrieval.
AI System Design Principles
- 80LLM Boundary Design
Treat LLM as non-deterministic dependency — DIP with LLMPort, timeouts, fallbacks, human escalation.
- 81RAG Architecture Principles
Retrieval-Augmented Generation — separate retrieval (SRP), generation, and evaluation concerns.
- 82Prompt Engineering Separation
Prompts as versioned artifacts — not scattered strings.
- 83AI Safety Guardrails
Input/output filters, PII redaction, rate limits — fail-fast on policy violation.
- 84Evaluation-Driven Design
Ship AI features with eval harness — golden sets, regression on model/prompt changes.
- 85Human-in-the-Loop Principles
High-stakes decisions require human confirmation — principle of least astonishment for users.
Staff Engineer Leadership Track
- 86Technical Leadership Principles
Lead through clarity, standards, and multiplied impact — not heroics or gatekeeping.
- 87Mentoring Through Principles
Teach smells and refactor moves — not answers.
- 88Cross Team Standardization
Standards where divergence hurts (security, observability); autonomy where it helps (domain models).
- 89Principle-Driven RFCs
RFCs state forces, options, trade-offs, decision — staff template used org-wide.
- 90Building Review Culture
Psychological safety + high standards — reviews teach, don't punish.
- 91Staff Promotion Narrative
Promotion case: scope, impact, principles applied at org scale — brag doc with metrics.
Refactoring Workshops
- 92Workshop: God Class
God class workshop — 450-line OrderManager: list smells, map to SRP, extract in 4 safe steps with tests.
- 93Workshop: Dependency Inversion
DIP workshop — concrete PostgresUserRepository inside UserService — introduce port, fake, wire DI.
- 94Workshop: Feature Envy
Feature envy workshop — ReportGenerator reaches into Order line items — move method to Order.
- 95Workshop: Long Parameter List
Long parameter list — 12-parameter createUser — introduce parameter object or builder with validation.
- 96Workshop: Switch Statements
Switch workshop — discount switch grows weekly — apply OCP with Strategy registry.
- 97Workshop: Parallel Change
Parallel change (Expand-Contract) — migrate API shape without breaking clients — Fowler branch by abstraction.