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:
- Gigi Sayfan - REST vs. gRPC: Battle of the APIs (2023)
- Microsoft - Compare gRPC services with HTTP APIs (2024)
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β
- Gang of Four Design Patterns: Comprehensive guide to 23 classic design patterns