Tags

Design Patterns

Design Patterns

0 lessons
2 problems
2 code snippets
8 question banks
21 community items

design-patterns

Practice Problems

2 problems

Design Add and Search Words

Not Started
Medium

Design a data structure that supports adding words and searching for words with wildcard characters, where '.' can match any single letter.

Trie / Prefix Tree
Trie Operations
DFS
Design Patterns
Strings
Intermediate

1k

14

Implement Trie (Prefix Tree)

Free
Not Started
Medium

Implement a trie (prefix tree) that supports inserting words, searching for exact words, and checking if any word starts with a given prefix.

Trie / Prefix Tree
Trie Operations
Design Patterns
Strings
Intermediate

555

13

Code Snippets

2 snippets
Code Snippet
Premium

Sealed Interfaces with Pattern Matching

Sealed interfaces (Java 17+) plus switch pattern matching (Java 21+) give Java algebraic-data-type ergonomics: a closed family of subtypes that the compiler can check exhaustively in one switch. This snippet shows the modern syntax in comments and a Java 13-compatible equivalent using a visitor-style abstract class hierarchy that compiles in our test runner. Use this pattern for tagged unions like `Result<Ok, Err>`, AST nodes, and state machines.

Java
java-sealed-classes
java-pattern-matching
type-system
design-patterns

1.1k

24

Hard
Code Snippet
Premium

Proxy Patterns: Validation, Logging, Defaults

`Proxy` lets you intercept the basic operations on an object (get, set, has, deleteProperty) and run your own logic before or instead of the default behavior. This snippet shows three of the most useful patterns: a validating Proxy that rejects bad writes at the source, a logging Proxy that records access for debugging, and a defaults-plus-locked Proxy that supplies fallbacks and freezes keys after init. Use sparingly because Proxy adds a small per-access cost; reach for it when you need cross-cutting policy on a plain data object.

JavaScript
js-proxy-reflect
references
design-patterns

1k

21

Hard

Question Banks

8 items
Question Bank
Premium

Design Patterns Walk-Through

Hard drills on Singleton, Strategy, Observer, and Decorator. Concrete Java implementations to read, critique, and extend, plus one thread-safety twist.

Java
design-patterns
oop
singleton
interview-prep

254

2

Hard
Question Bank

Event Delegation and Event Bus Quiz

Practice DOM event delegation, build a minimal pub/sub event bus, and roll your own dispatcher so cross-component communication stays decoupled.

JavaScript
quiz
js-event-delegation
js-dom
design-patterns

569

10

Medium
Question Bank
Premium

JavaScript Decorators and Metaprogramming Quiz

Wrap methods with cross-cutting concerns: a read-only decorator, a method-timing decorator, and the stage-3 decorator proposal that landed in TC39.

JavaScript
quiz
js-proxy-reflect
design-patterns
interview-prep

1k

24

Hard
Question Bank

React Router and Code Splitting Quiz

Four drills on declarative routing with react-router and using React.lazy plus Suspense to split bundles per route or per heavy component.

JavaScript
quiz
react
design-patterns
performance-optimization

150

2

Medium
Question Bank
Premium

React Component Patterns and Composition Quiz

Six drills on the classic React patterns: composition over inheritance, render props, higher-order components, compound components, and slot-style children.

JavaScript
quiz
react
design-patterns
composition

327

9

Hard
Question Bank

React Lifecycle and Class Component Quiz

Four drills on legacy class lifecycle methods that still show up in interviews and codebases: mount/update/unmount, getSnapshotBeforeUpdate, setState batching, and getDerivedStateFromProps.

JavaScript
quiz
react
interview-prep
design-patterns

157

1

Medium
Question Bank
Premium

React Code-Splitting: Two Explanations Quiz

Two explanations of code-splitting (bundler-level vs `React.lazy` + `Suspense`) plus companions on preloading routes and on splitting non-component utilities.

JavaScript
quiz
react
performance-optimization
design-patterns

896

7

Hard
Question Bank
Premium

React HOC for Conditional Render (Auth-Aware): Two Approaches Quiz

Two approaches to a conditional-render HOC for authentication (props-based gate vs context-based gate), plus companions on the hook equivalent and on the HOC return-type contract.

JavaScript
quiz
react
design-patterns
composition

1k

18

Hard

Community

21 items
Article

Python Decorators Explained with Five Real Examples

Decorators stop being magic the moment you see five real ones in a row: timing, caching, auth, retry, and rate limiting. Here is the pattern, the gotchas, and the line where I stop reaching for them.

py-decorators
design-patterns
functional-programming
interview-prep
fundamentals

1.1k

18

4.5 (11)

May 11, 2026

by @yunatorres

Article

The Builder Pattern: When the Constructor Isn't Enough

The Builder pattern earns its keep when constructors blow up to ten parameters or when an object's invariants depend on a multi-step assembly. The shape, the cases that justify it, and the imitations that don't.

design-patterns
patterns
oop
constructors
encapsulation

866

6

4.4 (10)

May 3, 2026

by @weireeves

Code Snippet

The mapStateToProps / mapDispatchToProps Cheatsheet I Wish I Had In 2018

Every React + Redux codebase from before hooks revolves around connect. Three accordions of the wiring I keep paged in for inheriting one of those repos.

JavaScript
react
design-patterns
state-machine

722

8

4.2 (9)

May 2, 2026

by @milozhang

Article

Functional Core, Imperative Shell, Explained

The architecture pattern that gives you most of functional programming's testability without a rewrite. The two-layer rule, where each layer's responsibilities sit, and the failure modes of mixing them.

functional-programming
design-patterns
patterns
pure-functions
clean-code

376

9

4.2 (15)

Apr 30, 2026

by @gracebanda

Article

Type Hints, mypy, and the Runtime Truth

Python type hints are documentation that a static checker reads. The runtime ignores them. Here is what hints do, what mypy adds, and the libraries that validate at runtime on purpose.

py-type-hints
abstraction
fundamentals
interview-prep
design-patterns

1k

25

4.4 (10)

Apr 18, 2026

by @imanichen

Code Snippet

The "Component Switch" Pattern I Use Instead of Big Render Trees

Big if/else ladders that pick a component by a tag are unreadable by the third branch. The pattern I use instead is a tiny lookup registry. Three accordions on shipping it.

JavaScript
react
hooks
design-patterns

780

25

4.5 (8)

Apr 9, 2026

by @diegonguyen

Article

Composition Over Inheritance, with Real Examples

The slogan everyone repeats and almost no one operationalizes. What composition actually looks like at the field level, where inheritance is still right, and the refactor when you've gone too deep.

composition
inheritance
design-patterns
oop
patterns

203

1

4.1 (10)

Apr 8, 2026

by @liamreed

Code Snippet

Four Things I Forget About Create-React-App Every Year

Cheat sheet for the CRA quirks that keep coming back. Absolute imports via jsconfig, the HTTPS dev flag, the registerServiceWorker mystery, and the REACT_APP_ env var rules.

JavaScript
react
design-patterns
references

308

6

4.3 (13)

Mar 29, 2026

by @yunatorres

Code Snippet

The HOC + Render Props Patterns I Still Read in Legacy Repos

Hooks made HOCs and render props optional, but pre-2019 codebases still ship them. Four patterns to recognize when you inherit a Redux-era React app.

JavaScript
react
higher-order-functions
design-patterns
references

808

20

4.2 (11)

Mar 7, 2026

by @diyahassan

Article

The Strategy Pattern: The Cleanest Way to Kill an if-else Chain

Strategy is taught as an OO pattern, but in practice it is just a function with a name. How to recognize the if-else chains that genuinely deserve the refactor and the ones that don't.

strategy-pattern
design-patterns
oop
patterns
clean-code

592

9

4.3 (12)

Mar 4, 2026

by @marcusreddy

Code Snippet

Three React Router v4 Recipes I Inherit With Old Codebases

RRv4 still survives in long-running codebases. Three recipes I keep paged in: programmatic navigation via withRouter, query parsing, and a custom history singleton for non-React callers.

JavaScript
react
design-patterns
references

1k

31

4.1 (11)

Mar 3, 2026

by @freyadiallo

Article

Building Smarter Code: Singleton & Factory Method

Singleton is the pattern most teams over-apply, and Factory Method is the one most teams reach for too late. Where each pays off, where each rots, and the rules I follow.

singleton
factory-pattern
design-patterns
oop
patterns

769

5

4.2 (13)

Mar 1, 2026

by @aishataylor

Article

The Observer Pattern and Why React Rediscovered It

Observer is the pattern most engineers think they know, until they look at React's render loop, signals, or RxJS and realize each one is a different observer dialect. The shape, the variants, and the gotchas.

observer-pattern
design-patterns
event-driven
react
patterns

235

6

4.3 (14)

Feb 25, 2026

by @hannahdelgado

Article

The Decorator Pattern vs Language Decorators

The GoF Decorator pattern and Python's @decorator syntax share a name and almost nothing else. What each one really does, where they overlap, and the wrap order that catches everyone.

decorator-pattern
py-decorators
ts-decorators
design-patterns
patterns

662

7

4.2 (13)

Feb 23, 2026

by @kiranpatel

Article

dataclasses, attrs, and pydantic: Pick One

Three libraries solve the data-container problem and they answer different questions. dataclasses for internal objects, attrs for power-user customisation, pydantic for validating external input.

py-dataclasses
py-type-hints
design-patterns
abstraction
interview-prep

306

9

4.4 (10)

Feb 3, 2026

by @yasminromero

Article

Pure Functions, Immutability, and the Trade-offs

Pure functions and immutability are not free. The honest accounting of the wins (testability, reasoning, parallelism) and the costs (allocation, ergonomics, language fit), and where the line falls in real code.

pure-functions
immutability
functional-programming
design-patterns
patterns

595

2

4.2 (15)

Jan 31, 2026

by @imanichen

Code Snippet

Route-Level Code Splitting With React.lazy

Our initial bundle was 2.1MB. Splitting routes via React.lazy plus Suspense dropped it to 340KB on first paint. Three accordions on how I wire it.

JavaScript
react
performance-optimization
design-patterns

835

4

4.5 (10)

Jan 24, 2026

by @meinakamura

Article

Python Packaging in 2026: pyproject, uv, and pipx

Python packaging finally converged. pyproject.toml is the source of truth, uv replaced pip plus venv plus pip-tools, and pipx owns global CLIs. The modern toolchain and the migration order that does not blow up CI.

py-virtual-environments
py-standard-library
fundamentals
design-patterns
interview-prep

953

31

4.4 (11)

Jan 24, 2026

by @kavyachakraborty

Question Bundle
$12.99

The CSS-in-JS Tradeoffs I Keep Explaining to Juniors

Five conversations I keep having: the styling-approach overview, build-time vs runtime CSS-in-JS, CSS Modules vs Tailwind, the styled-components performance trap I keep flagging, and when to walk back to plain CSS.

JavaScript
react
design-patterns
interview-prep
performance-optimization

288

8

4.2 (11)

Dec 16, 2025

by @sophiesharma

Article

Adapter and Facade: The Two Patterns I Actually Use

Two structural patterns that survive every codebase: Adapter (when you cannot change the other side) and Facade (when you cannot change yours). The shape of each, and the small tells that say which one fits.

design-patterns
patterns
oop
abstraction
encapsulation

1k

27

4.3 (12)

Dec 15, 2025

by @sanjayward

Article

Dependency Injection Without a Framework

DI is a pattern, not a framework. The plain-language version (pass things in instead of newing them inside) covers ninety percent of cases. The trade-off versus DI containers, and where each one breaks down.

design-patterns
patterns
oop
abstraction
testing

490

5

4.3 (14)

Dec 4, 2025

by @ramijohansson