StackPractices

design

Practical resources about design for software engineers.

150 results

Patterns for Maintainable Code

Design patterns are not cookbook recipes — they are a shared vocabulary for discussing solutions to recurring problems. Knowing when to apply (and when to avoid) a pattern is a hallmark of senior engineering.

Browse our catalog of creational, structural, and behavioral patterns. Each entry includes a real-world scenario, UML diagrams, implementation in multiple languages, and a discussion of trade-offs. From Singleton to Outbox, find the right tool for your context.

intermediate

Database per Service Pattern

Give each microservice its own private database to ensure loose coupling, independent deployment,...

intermediate

Decorator Pattern

Add new functionality to objects dynamically by wrapping them. A structural design pattern for...

intermediate

Decorator Pattern for HTTP Request Pipelines

Use the Decorator pattern to compose cross-cutting concerns like logging, metrics, and retries into...

intermediate

Dependency Injection Pattern

Supply dependencies from outside rather than creating them internally. An architectural pattern for...

intermediate

Dependency Injection Container in TypeScript

Build a lightweight DI container in TypeScript with singleton, transient, and scoped lifetimes, so...

intermediate

Distributed Lock Pattern with Redis, ZooKeeper, and etcd

Coordinate exclusive access to shared resources across distributed nodes using Redis, ZooKeeper, or...

intermediate

Domain Event Pattern

Capture and publish major occurrences within a domain model to decouple side effects from core...

intermediate

Eager Loading Pattern: Fix the N+1 Problem

Load related data in a single query rather than multiple round-trips, preventing the N+1 problem...

advanced

Entity-Component-System (ECS) Pattern

Compose entities from pure data components and process them with systems, enabling high-performance...

intermediate

Event Bus Pattern

Decouple components by routing events through a central bus. A behavioral pattern for loosely...

intermediate

Event-Carried State Transfer Pattern

Replicate state changes across services by publishing events that carry the full updated entity...

advanced

Event Sourcing Pattern

Store the state of an application as a sequence of events rather than storing only the current...

beginner

Facade Pattern

Provide a simplified interface to a complex subsystem. A structural pattern that hides...

beginner

Factory Pattern

Create objects without specifying the exact class to instantiate. A creational design pattern for...

intermediate

Flyweight Pattern: Shared Objects for Memory Efficiency

Use the Flyweight pattern to share object state and cut memory usage. See Python, JavaScript, and...

intermediate

Flyweight Pattern for Efficient Large-Scale Object Sharing

Use the Flyweight pattern to minimize memory usage by sharing as much data as possible between...

intermediate

Front Controller Pattern in Java, Python and PHP

Route all incoming requests through a single handler that dispatches to the appropriate page...

intermediate

Gatekeeper Pattern: Centralized Edge Security

Centralize authentication, rate limiting, and input sanitization at the system edge. Gatekeeper...

intermediate

Graceful Degradation Pattern

Degrade functionality instead of failing when dependencies are unavailable. Serve partial results,...

intermediate

Idempotent Consumer Pattern

Process messages from a queue exactly once regardless of duplicates by using idempotent operations,...

No results found.