Skip to main content

Design Patterns

This document summarizes key software design patterns, architectural principles, and related concepts for building robust applications.

Creational Patterns​

Inversion of Control & Dependency Injection​

Inversion of Control (IoC) is a design principle where the control flow of a program is inverted, and Dependency Injection (DI) is a technique to implement IoC by passing dependencies to objects rather than creating them internally.

πŸ’‘ This promotes loose coupling and testability.

πŸ“ Martin Fowler - Inversion of Control Containers and the Dependency Injection pattern (2004)

Architectural Patterns​

Hexagonal Architecture​

Also known as Ports and Adapters, this architecture isolates business logic from external systems (e.g., UI, databases) through well-defined interfaces (ports) and implementations (adapters). It enhances modularity and testability.

πŸ’‘ Ideal for microservices and systems requiring flexibility in swapping out external dependencies.

πŸ“ Read more:

Data Access Patterns​

Active Record​

An object that wraps a row in a database table, encapsulating both data and behavior (e.g., CRUD operations). Common in ORMs like Ruby on Rails.

πŸ’‘ Simple for small applications but may couple business logic too tightly to the database.

πŸ“ Martin Fowler - Active Record (2003)

Table Data Gateway​

An object that acts as a gateway to a database table, providing a simple interface for all SQL operations on that table.

πŸ’‘ Useful for encapsulating database access logic, especially in systems with complex queries.

πŸ“ Martin Fowler - Table Data Gateway (2003)

Row Data Gateway​

An object that represents a single row in a database table, acting as a data holder without business logic.

πŸ’‘ Works well with Table Data Gateway for separating data access and manipulation.

πŸ“ Martin Fowler - Row Data Gateway

Feature Flags​

Feature flags enable continuous deployment by allowing new functionality to be deployed but toggled on/off without redeployment. They support progressive exposure but come with management overhead.

πŸ’‘ Useful for A/B testing, canary releases, and managing feature rollouts in production.

Willy-Peter Schaub - What's the cost of feature flags? (2018)

Communication Protocols​

REST​

Representational State Transfer (REST) is a widely-used architectural style for designing networked applications, relying on stateless, client-server communication via HTTP.

πŸ’‘ As of 2025, REST remains the dominant choice for APIs due to its simplicity and compatibility.

gRPC​

A high-performance, open-source framework for remote procedure calls, using HTTP/2 and Protocol Buffers. It’s optimized for microservices and low-latency communication.

πŸ’‘ gRPC is gaining traction for new microservices due to its performance benefits over REST.

πŸ“ Read more:

Authentication​

Mechanisms to verify user or system identity, often involving tokens for secure access.

Refresh Tokens​

Tokens used to obtain new access tokens without re-authenticating, improving security and user experience.

πŸ’‘ Essential for secure API access, especially in distributed systems.

πŸ“ Auth0 - Understanding Refresh Tokens

Additional Resources​