Core CS
Design Patterns & OOP
Object-oriented design from first principles: the four pillars, SOLID, composition vs inheritance, and every Gang-of-Four pattern with the problem it solves, a diagram, and code.
5 modules 24 lessons ~1 h of reading
Start learning
0/24 completed
01
Foundations
3 lessons- 1OOP FundamentalsClasses and objects, the four pillars (encapsulation, abstraction, inheritance, polymorphism), interfaces vs abstract classes, composition over inheritance, and how dynamic dispatch works.beginner4 min
- 2SOLID PrinciplesThe five SOLID principles with before-and-after code — single responsibility, open/closed, Liskov substitution, interface segregation and dependency inversion — plus when not to apply them.intermediate3 min
- 3UML & Class RelationshipsReading and drawing class diagrams — association, aggregation, composition, inheritance, realisation and dependency — plus multiplicity, sequence diagrams, and how to sketch them in interviews.beginner2 min
02
Creational
4 lessons- 4SingletonEnsuring a class has exactly one instance — thread-safe implementations (eager, holder idiom, double-checked locking, enum), module singletons in Python and JS, and why singletons are often an anti-pattern.beginner2 min
- 5Factory Method & Abstract FactoryDecoupling object creation from use — simple factories, the Factory Method pattern, Abstract Factory for families of related objects, registries, and how they look in Java, Python and TypeScript.intermediate2 min
- 6BuilderConstructing complex objects step by step — the telescoping constructor problem, fluent builders with validation, immutable results, step builders, and idiomatic alternatives in Python and TypeScript.beginner1 min
- 7PrototypeCreating objects by cloning existing ones — shallow vs deep copies, copy constructors, prototype registries, and how JavaScript's prototype chain relates.beginner1 min
03
Structural
6 lessons- 8AdapterMaking incompatible interfaces work together — object vs class adapters, wrapping third-party SDKs and legacy code, and the anti-corruption layer.beginner2 min
- 9DecoratorAdding behaviour to objects dynamically by wrapping them — stacking decorators, Java I/O streams, Python function decorators, middleware, and decorator vs inheritance.intermediate2 min
- 10FacadeProviding a simple, unified interface over a complex subsystem — examples, layering, facades vs service classes, and the risk of god objects.beginner1 min
- 11ProxyA stand-in that controls access to another object — virtual (lazy), protection, remote, caching and logging proxies, dynamic proxies in Java, JavaScript Proxy objects, and how frameworks use them.intermediate2 min
- 12CompositeTreating individual objects and groups uniformly with tree structures — file systems, UI trees, expression trees, recursive operations, and transparency vs safety trade-offs.intermediate2 min
- 13Bridge & FlyweightBridge separates an abstraction from its implementation so both can vary independently; Flyweight shares intrinsic state to support huge numbers of fine-grained objects.intermediate2 min
04
Behavioral
8 lessons- 14StrategyEncapsulating interchangeable algorithms behind a common interface — replacing conditionals, choosing strategies at runtime, strategies as functions, and real-world uses like comparators and pricing rules.beginner2 min
- 15ObserverOne-to-many notification when state changes — subjects and observers, push vs pull, event emitters, pub/sub, reactive streams, memory leaks from forgotten subscriptions, and thread-safety concerns.intermediate2 min
- 16CommandTurning requests into objects — invokers and receivers, undo/redo stacks, macro commands, job queues, and how commands relate to callbacks and event sourcing.intermediate2 min
- 17StateLetting an object change behaviour when its internal state changes — finite state machines, state classes vs transition tables, an order lifecycle example, and when enums suffice.intermediate2 min
- 18Template MethodDefining an algorithm's skeleton in a base class and letting subclasses fill in steps — hooks, the Hollywood principle, framework examples, and replacing inheritance with composition.beginner2 min
- 19IteratorTraversing a collection without exposing its representation — external vs internal iteration, Java Iterator/Iterable, Python's iterator protocol and generators, JavaScript's Symbol.iterator, lazy and infinite sequences.beginner2 min
- 20Chain of ResponsibilityPassing a request along a chain of handlers until one handles it — middleware pipelines, validation chains, approval workflows, and the variant where every handler participates.intermediate2 min
- 21Mediator, Memento & VisitorThree remaining GoF behavioural patterns — Mediator centralises communication between components, Memento captures and restores state, and Visitor adds operations to object structures without changing them. Plus brief notes on Interpreter.advanced3 min
05
Beyond GoF
3 lessons- 22Dependency InjectionSupplying an object's dependencies from outside — constructor, setter and interface injection, the composition root, DI containers (Spring, Guice, FastAPI, NestJS), scopes, and testing with fakes.intermediate2 min
- 23Anti-Patterns & Code SmellsRecognising bad design — god objects, spaghetti code, golden hammers, premature abstraction, primitive obsession, feature envy and more — with the refactorings that fix them.intermediate4 min
- 24Low-Level Design InterviewsA repeatable approach to object-oriented design interviews — clarifying requirements, finding entities, assigning responsibilities, applying patterns — with a fully worked parking lot design and a list of common problems.advanced4 min