Skip to content

Design Principles and Patterns

Foundations for low-level design. Each page starts from a problem, builds the intuition, then gives the formal definition, code and where it is used in practice.

Topic What it covers
Factory Design Pattern Simple Factory, Factory Method and Abstract Factory: definitions, a worked Notification Service design (class diagrams, decisions, tradeoffs, runnable tested code), real-world uses, interview questions
Strategy Design Pattern Interchangeable algorithms behind one interface: definition, a worked cache with pluggable eviction policies (class and sequence diagrams, decisions, tradeoffs, runnable tested code), class versus function, real-world uses, interview questions
Observer Design Pattern One-to-many notification: definition, a worked stock price feed with alerts (class and sequence diagrams, decisions, tradeoffs, the classic pitfalls demonstrated, runnable tested code), Observer versus Pub/Sub, real-world uses, interview questions
Singleton Design Pattern One shared instance with global access: definition, a worked thread-safe Logger design (class diagram, decisions, tradeoffs, runnable code), real-world uses, interview questions