Skip to main content

29 docs tagged with "oop"

View all tags

Class basics

In this chapter, you learn the basics of how to write classes in TypeScript.

Cohesion, coupling, and SOLID in review

Where Part 1 comes together. Fills in the open-closed, Liskov substitution, and interface segregation principles, then revisits everything so far through cohesion and coupling.

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 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.

Introduction — why learn class design

Chapter 1 of the PHP Class Design Guide. Through real examples of god classes and code that resists change, it shows what class design is for and lays out the shape of the whole series.

OOP and the Tactical Patterns — Where the Principles Show Up

Rereads value objects, aggregates, and domain services from the side of object-oriented principles. It maps which pattern encapsulation, composition, and polymorphism each show up in, and what the pattern adds on top. The principles themselves are left to the PHP Class Design Guide.

PHP Class Design Guide

A 14-chapter guide that takes class design in PHP from first principles to practice. It runs from framework-independent design principles (encapsulation, single responsibility, inheritance versus composition, interfaces, SOLID) through to model and service class design in Laravel.

PHP class syntax basics

The basic syntax of classes in PHP. Covers properties, methods, constructors, visibility modifiers, readonly, constructor promotion, and enum.

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.

The single responsibility principle

The single responsibility principle and the idea of keeping classes small. Covers the signs of a god class and a worked example of splitting responsibilities.

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.