Skip to main content

19 docs tagged with "design-patterns"

View all tags

Decorator — A Pattern Distinct from TC39 Decorators

Despite the shared name, GoF's Decorator pattern and TypeScript's Decorators syntax are different concepts. This chapter separates the two, then compares the pattern with composition through higher-order functions.

Design & Quality

A hub for the domain covering how code is written and structured. It spans everyday decisions such as naming and splitting functions, a closer look at the SOLID principles, a rereading of the GoF patterns in modern TypeScript, and what changes when the test comes first.

Design patterns — four archetypes and their vocabulary

This chapter presents Strategy, Singleton, Observer, and Abstract Factory from the problems each was designed to solve. It covers commonly conflated pairs like Strategy vs. State, Observer vs. polling, and Abstract Factory vs. Factory Method.

Singleton — How Far a Module's Single Instance Reaches

An ES module is evaluated only once as long as it resolves to the same URL, so you get a single instance without writing a Singleton class. This chapter maps how far that guarantee reaches and when you still need another approach.

Strategy — Functions Being First-Class

If all you do is swap behavior, passing a function is enough. What still makes you want to bundle things into an object is a strategy that carries several methods or state.

TypeScript Design Patterns

A 16-chapter guide that rereads the 23 GoF patterns in modern TypeScript. Each chapter judges whether language features can replace the pattern, and lays out the conditions under which writing it as a class still pays off.