360 Secure SkillHub
360 安全技能中心

Java Design Patterns

面向 Java 开发者的设计模式与设计原则参考,按创建型、结构型、行为型、架构、并发等分类索引 182 个模式,并提供原则说明、常用模式示例与模式选择建议。

wufengsheng
wufengsheng
热度 20.70
最近更新 2026-06-25 13:45:45
分类:知识依赖:读写文件应用场景:概念解释 / 教学辅导 / 代码审查 / 研究

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add java-design-patterns
Metadata
name
java-design-patterns
description
Java 设计模式权威参考。涵盖 GoF 23 种经典模式及企业级架构模式的完整 Java 实现,含 26 个核心设计原则。当用户询问设计模式、架构模式、设计原则(KISS/DRY/SOLID/GRASP 等)、Java 模式实现、或需要选择合适的设计模式时调用此技能。覆盖创建型、结构型、行为型、架构型、并发型等 15 大类 182 个模式 + 26 个设计原则。

Java 设计模式技能

官方文档:java-design-patterns.com 模式总数:182 个,覆盖 15 个分类 设计原则:26 个核心编程原则 代码语言:Java

触发条件

在以下场景中自动调用此技能:

  1. 用户询问"设计模式"、"Design Pattern"、"GoF" 等相关话题
  2. 用户需要了解特定设计模式的 Java 实现
  3. 用户在代码审查或架构设计时需要选择合适的设计模式
  4. 用户询问"如何实现..."且可通过设计模式解决的问题
  5. 用户讨论软件架构、企业级应用架构方案
  6. 用户询问并发模式、微服务模式、数据访问模式等
  7. 用户询问"设计原则"、"编程原则"、"SOLID"、"KISS"、"DRY"、"YAGNI"等软件设计原则

使用优先级

重要:回答设计问题时,遵循以下优先级:

  1. 先原则后模式 — 先基于设计原则判断方向(为什么这样做),再选择合适的设计模式(具体怎么做)
  2. 设计原则是决策基础 — 当用户询问"如何设计/优化/重构"时,优先从原则角度给出建议,再推荐具体模式
  3. 经典代码示例 — 快速参考 7 个最常用模式的 Java 实现,可直接用于回答代码问题
  4. 按需深入 — 当需要某个模式的完整 API、类图、适用场景时,通过链接读取对应的 references/ 文档

设计原则快速索引

全部来自 https://java-design-patterns.com/principles/ ,共 25 个核心编程原则。

原则 说明 文档
KISS 保持简单 — 系统越简单越有效 kiss
YAGNI 你不会需要它 — 不实现不必要的功能 yagni
DRY 不要重复自己 — 每份知识唯一表达 dry
Separation of Concerns 关注点分离 — 程序按关注点分模块 separation-of-concerns
Single Responsibility (SRP) 单一职责 — 一个类只有一个变化理由 single-responsibility-principle
Open/Closed (OCP) 开闭原则 — 对扩展开放,对修改关闭 open-closed-principle
Liskov Substitution (LSP) 里氏替换 — 子类型可透明替换父类型 liskov-substitution-principle
Interface Segregation (ISP) 接口隔离 — 避免胖接口 interface-segregation-principle
Composition Over Inheritance 组合优于继承 — 优先使用组合而非继承 composition-over-inheritance
Encapsulate What Changes 封装变化 — 识别变化点并封装 encapsulate-what-changes
Minimise Coupling 最小化耦合 — 降低模块间依赖 minimise-coupling
Maximise Cohesion 最大化内聚 — 相关功能集中到单一模块 maximise-cohesion
Hide Implementation Details 隐藏实现细节 — 通过接口隐藏内部实现 hide-implementation-details
Law of Demeter 迪米特法则 — 不要和陌生人说话 law-of-demeter
Inversion of Control 控制反转 — 别调用我们,我们会调用你 inversion-of-control
Command Query Separation 命令查询分离 — 查询不修改状态 command-query-separation
Avoid Premature Optimization 避免过早优化 — 先让它工作,再优化 avoid-premature-optimization
Code For The Maintainer 为维护者编码 — 代码应易于维护和理解 code-for-the-maintainer
Boy-Scout Rule 童子军规则 — 让代码比发现时更干净 boy-scout-rule
Robustness Principle 健壮性原则 — 严以律己,宽以待人 robustness-principle
Orthogonality 正交性 — 不相关的事物不应在系统中相关 orthogonality
Curly's Law 科里定律 — 只做一件事 curlys-law
Murphy's Law 墨菲定律 — 可能出错的终将出错 murphys-law
Brooks's Law 布鲁克斯定律 — 向延期项目加人只会更延期 brooks-law
Linus's Law 林纳斯定律 — 足够多的眼球,所有 Bug 都是浅显的 linus-law

经典代码示例

单例模式(Singleton)— 双重检查锁定

public class Singleton {
    private static volatile Singleton instance;

    private Singleton() {}

    public static Singleton getInstance() {
        if (instance == null) {
            synchronized (Singleton.class) {
                if (instance == null) {
                    instance = new Singleton();
                }
            }
        }
        return instance;
    }
}

工厂方法模式(Factory Method)

interface Product { void use(); }

class ConcreteProductA implements Product {
    public void use() { System.out.println("Using Product A"); }
}

abstract class Creator {
    abstract Product createProduct();
    void doSomething() {
        Product p = createProduct();
        p.use();
    }
}

观察者模式(Observer)

interface Observer {
    void update(String message);
}

class Subject {
    private final List<Observer> observers = new ArrayList<>();

    void attach(Observer o) { observers.add(o); }
    void detach(Observer o) { observers.remove(o); }

    void notifyObservers(String msg) {
        observers.forEach(o -> o.update(msg));
    }
}

策略模式(Strategy)

interface Strategy {
    int execute(int a, int b);
}

class AddStrategy implements Strategy {
    public int execute(int a, int b) { return a + b; }
}

class Context {
    private Strategy strategy;

    void setStrategy(Strategy s) { this.strategy = s; }
    int executeStrategy(int a, int b) { return strategy.execute(a, b); }
}

装饰器模式(Decorator)

interface Coffee {
    double getCost();
    String getDescription();
}

class SimpleCoffee implements Coffee {
    public double getCost() { return 1.0; }
    public String getDescription() { return "Simple coffee"; }
}

class MilkDecorator implements Coffee {
    private final Coffee coffee;

    MilkDecorator(Coffee c) { this.coffee = c; }

    public double getCost() { return coffee.getCost() + 0.5; }
    public String getDescription() { return coffee.getDescription() + ", milk"; }
}

建造者模式(Builder)

public class Hero {
    private final String name;
    private final String profession;

    private Hero(Builder builder) {
        this.name = builder.name;
        this.profession = builder.profession;
    }

    public static class Builder {
        private String name;
        private String profession;

        public Builder name(String name) { this.name = name; return this; }
        public Builder profession(String p) { this.profession = p; return this; }
        public Hero build() { return new Hero(this); }
    }
}

// 使用
Hero hero = new Hero.Builder()
    .name("Arthur")
    .profession("Warrior")
    .build();

适配器模式(Adapter)

// 已有接口
interface OldSystem { void oldMethod(); }

// 新接口
interface NewSystem { void newMethod(); }

// 适配器
class Adapter implements NewSystem {
    private final OldSystem oldSystem;

    Adapter(OldSystem old) { this.oldSystem = old; }

    public void newMethod() { oldSystem.oldMethod(); }
}

模式快速索引

创建型模式(Creational)— 14 个

模式 说明 文档
Abstract Factory 抽象工厂 — 创建相关对象家族,无需指定具体类 abstract-factory
Builder 建造者 — 分步构建复杂对象 builder
Dependency Injection 依赖注入 — 将依赖从外部注入对象 dependency-injection
Factory 工厂 — 提供统一的对象创建接口 factory
Factory Kit 工厂套件 — 使用 Builder 和 Functional 接口创建工厂 factory-kit
Factory Method 工厂方法 — 子类决定实例化哪个类 factory-method
Monostate 单态 — 通过静态成员实现类似单例的行为 monostate
Multiton 多例 — 控制实例数量的单例变体 multiton
Object Pool 对象池 — 重用开销大的对象 object-pool
Prototype 原型 — 克隆已有对象 prototype
Registry 注册表 — 集中管理对象的查找和获取 registry
Singleton 单例 — 全局唯一实例 singleton
Step Builder 步骤建造者 — 强制按步骤构建对象的建造者变体 step-builder
Type Object 类型对象 — 通过对象实例表示类型 type-object

结构型模式(Structural)— 35 个

模式 说明 文档
Abstract Document 抽象文档 — 动态添加属性 abstract-document
Adapter 适配器 — 转换接口使不兼容的类可以协作 adapter
Bridge 桥接 — 将抽象与实现分离 bridge
Business Delegate 业务代表 — 解耦表示层和业务服务层 business-delegate
Component 组件 — 通过统一接口管理对象组 component
Composite 组合 — 树形结构表示整体-部分层次 composite
Composite Entity 组合实体 — 管理一组相关持久化对象 composite-entity
Composite View 组合视图 — 聚合多个子视图 composite-view
Converter 转换器 — 对象间相互转换 converter
Curiously Recurring Template Pattern CRTP — 通过模板实现编译期多态 curiously-recurring-template-pattern
DAO Factory DAO 工厂 — 灵活的数据访问层切换 dao-factory
Data Access Object (DAO) 数据访问对象 — 抽象持久化操作 data-access-object
Data Transfer Object (DTO) 数据传输对象 — 子系统间高效传递数据 data-transfer-object
Decorator 装饰器 — 动态添加职责 decorator
Domain Model 领域模型 — 封装业务逻辑的对象模型 domain-model
Dynamic Proxy 动态代理 — 运行时创建代理对象 dynamic-proxy
Extension Objects 扩展对象 — 灵活扩展对象功能 extension-objects
Facade 外观 — 简化复杂子系统的接口 facade
Flyweight 享元 — 共享细粒度对象以减少内存 flyweight
Marker Interface 标记接口 — 通过空接口定义行为 marker-interface
Money 货币 — 封装货币值和精度 money
Parameter Object 参数对象 — 简化方法签名 parameter-object
Private Class Data 私有类数据 — 保护数据完整性 private-class-data
Proxy 代理 — 控制对对象的访问 proxy
Role Object 角色对象 — 动态赋予对象不同角色 role-object
Separated Interface 分离接口 — 接口与实现分开打包 separated-interface
Servant 仆人 — 为多个类提供公共行为 servant
Service Locator 服务定位器 — 简化复杂系统中的服务访问 service-locator
Session Facade 会话外观 — 简化企业 Bean 接口 session-facade
Spatial Partition 空间分区 — 优化空间查询性能 spatial-partition
Special Case 特例 — 用预定义对象替代 null special-case
Strangler 绞杀者 — 逐步替换遗留系统 strangler
Twin 双生子 — 让不支持多继承的语言实现多重行为 twin
Value Object 值对象 — 不可变数据类型提升性能 value-object
Virtual Proxy 虚拟代理 — 延迟加载重型对象 virtual-proxy

行为型模式(Behavioral)— 40 个

模式 说明 文档
Acyclic Visitor 无环访问者 — 无循环依赖的访问者变体 acyclic-visitor
Bytecode 字节码 — 通过自定义虚拟机解释指令 bytecode
Chain of Responsibility 责任链 — 沿链传递请求直到被处理 chain-of-responsibility
Client Session 客户端会话 — 管理跨会话的客户端数据 client-session
Collecting Parameter 收集参数 — 在方法调用链中累积结果 collecting-parameter
Command 命令 — 封装请求为对象 command
Commander 指挥官 — 编排复杂命令执行 commander
Context Object 上下文对象 — 封装和传递上下文数据 context-object
Data Mapper 数据映射器 — 解耦对象模型和数据存储 data-mapper
Delegation 委托 — 将任务委托给关联对象 delegation
Dirty Flag 脏标记 — 跟踪变化避免不必要更新 dirty-flag
Double Buffer 双缓冲 — 平滑动画和图形渲染 double-buffer
Double Dispatch 双分派 — 根据接收者和参数类型动态调用 double-dispatch
Execute Around 环绕执行 — 封装前置和后置操作 execute-around
Feature Toggle 特性开关 — 无缝管理生产环境功能 feature-toggle
Filterer 过滤器 — 动态过滤数据流 filterer
Fluent Interface 流式接口 — 链式调用提升代码表达力 fluent-interface
Game Loop 游戏循环 — 游戏主循环驱动帧更新 game-loop
Health Check 健康检查 — 监控系统健康状态 health-check
Identity Map 标识映射 — 确保每个对象只加载一次 identity-map
Interpreter 解释器 — 定义语言的语法解释器 interpreter
Iterator 迭代器 — 顺序访问集合元素 iterator
Mediator 中介者 — 集中管理对象间通信 mediator
Memento 备忘录 — 保存和恢复对象状态 memento
Mute Idiom 静默惯用法 — 无侵入的异常抑制 mute-idiom
Notification 通知 — 事件告警增强系统通信 notification
Null Object 空对象 — 用无操作对象替代 null null-object
Observer 观察者 — 一对多状态变化通知 observer
Partial Response 部分响应 — 按需发送数据优化传输 partial-response
Pipeline 管道 — 多阶段数据处理 pipeline
Property 属性 — 动态属性管理 property
Rate Limiting 限流 — 控制请求速率防止过载 rate-limiting-pattern
Specification 规格 — 组合业务规则实现灵活查询 specification
State 状态 — 根据内部状态改变行为 state
Strategy 策略 — 算法族可互换 strategy
Subclass Sandbox 子类沙箱 — 限定子类可用的操作集合 subclass-sandbox
Template Method 模板方法 — 定义算法骨架,子类实现步骤 template-method
Template View 模板视图 — 动态网页渲染 templateview
Update Method 更新方法 — 系统化更新游戏对象 update-method
Visitor 访问者 — 在不修改类的前提下添加新操作 visitor

架构模式(Architectural)— 25 个

模式 说明 文档
Bloc Bloc — 状态管理简化 bloc
Clean Architecture 整洁架构 — 可维护的架构风格 clean-architecture
CQRS 命令查询职责分离 — 优化数据交互 command-query-responsibility-segregation
Event-Driven Architecture 事件驱动架构 — 构建响应式可扩展系统 event-driven-architecture
Event Sourcing 事件溯源 — 用事件记录构建不可变历史 event-sourcing
Flux Flux — 单向数据流简化复杂 UI flux
Front Controller 前端控制器 — 集中处理 Web 请求 front-controller
Hexagonal Architecture 六边形架构 — 解耦核心逻辑 hexagonal-architecture
Intercepting Filter 拦截过滤器 — 增强 Web 请求处理 intercepting-filter
Layered Architecture 分层架构 — 构建可扩展可维护应用 layered-architecture
Microservices Aggregator 微服务聚合器 — 构建复合服务 microservices-aggregrator
Microservices Client-Side UI Composition 客户端 UI 组合 — 组装微服务 UI microservices-client-side-ui-composition
Microservices Distributed Tracing 分布式追踪 — 增强服务通信可见性 microservices-distributed-tracing
Model-View-Controller (MVC) MVC — 分离模型、视图和控制器 model-view-controller
Model-View-Intent (MVI) MVI — 构建稳健可扩展的 UI model-view-intent
Model-View-Presenter (MVP) MVP — 增强 UI 逻辑分离 model-view-presenter
Model-View-ViewModel (MVVM) MVVM — 分离 UI 和逻辑 model-view-viewmodel
Monolithic Architecture 单体架构 — 内聚应用模型 monolithic-architecture
Naked Objects 裸对象 — 利用领域对象动态生成 UI naked-objects
Page Controller 页面控制器 — 集中管理页面逻辑 page-controller
Polling Pub/Sub 轮询发布订阅 — 异步消息优雅处理 polling-publisher
Presentation Model 展示模型 — 增强 UI 数据管理 presentation-model
Service Layer 服务层 — 增强应用架构的稳固服务层 service-layer
Service to Worker 服务到工作者 — 增强 UI 和业务逻辑集成 service-to-worker
View Helper 视图助手 — 简化 MVC 中的展示逻辑 view-helper

并发模式(Concurrency)— 22 个

模式 说明 文档
Active Object 活动对象 — 高效异步处理 active-object
Actor Model Actor 模型 — 优雅构建并发系统 actor-model
Async Method Invocation 异步方法调用 — 提升性能的异步编程 async-method-invocation
Backpressure 背压 — 防止生产者过载消费者 backpressure
Balking 犹豫 — 条件不满足时立即返回 balking
Double-Checked Locking 双重检查锁定 — 最小开销确保线程安全 double-checked-locking
Event-Based Asynchronous 基于事件的异步 — 非阻塞系统设计 event-based-asynchronous
Event Queue 事件队列 — 高效管理并发事件 event-queue
Fan-Out/Fan-In 扇出扇入 — 最大化并发数据处理 fanout-fanin
Guarded Suspension 守护挂起 — 安全控制临界区并发 guarded-suspension
Half-Sync/Half-Async 半同步半异步 — 双处理模式提升系统性能 half-sync-half-async
Leader Election 领导者选举 — 节点协调和共识 leader-election
Leader-Followers 领导者跟随者 — 动态分配工作者 leader-followers
Lockable Object 可锁定对象 — 稳健同步机制 lockable-object
Master-Worker 主从 — 协调并发处理 master-worker
Monitor 监视器 — 用 monitor 实现稳健锁定 monitor
Poison Pill 毒丸 — 优雅终止多线程处理 poison-pill
Producer-Consumer 生产者消费者 — 优化生产消费流程 producer-consumer
Promise Promise — 简化异步任务提升性能 promise
Reactor 反应器 — 非阻塞事件驱动架构 reactor
Thread-Pool Executor 线程池执行器 — 高效并发任务管理 thread-pool-executor
Thread-Specific Storage 线程特定存储 — 隔离的线程局部数据 thread-specific-storage

数据访问模式(Data Access)— 12 个

模式 说明 文档
Metadata Mapping 元数据映射 — 无缝桥接对象和数据存储 metadata-mapping
Optimistic Offline Lock 乐观离线锁 — 数据库事务冲突解决 optimistic-offline-lock
Repository 仓储 — 用抽象持久化简化数据访问 repository
Serialized Entity 序列化实体 — 简化数据持久化和交换 serialized-entity
Serialized LOB 序列化大对象 — 管理大型数据对象 serialized-lob
Sharding 分片 — 水平分区提升吞吐量 sharding
Single Table Inheritance 单表继承 — 统一表结构的对象映射 single-table-inheritance
Table Inheritance 表继承 — 关系数据库中的层次数据建模 table-inheritance
Table Module 表模块 — 有组织的数据处理模块 table-module
Transaction Script 事务脚本 — 整合的业务逻辑脚本 transaction-script
Unit of Work 工作单元 — 高效事务管理 unit-of-work
Version Number 版本号 — 稳健的版本管理 version-number

函数式模式(Functional)— 8 个

模式 说明 文档
Callback 回调 — 异步通信 callback
Collection Pipeline 集合管道 — 简化数据操作 collection-pipeline
Combinator 组合子 — 灵活的代码组合 combinator
Currying 柯里化 — 增强函数灵活性和重用性 currying
Function Composition 函数组合 — 优雅的函数式管道 function-composition
MapReduce MapReduce — 并行数据处理 map-reduce
Monad Monad — 函数式编程范式 monad
Trampoline 蹦床 — 无栈溢出的递归 trampoline

集成模式(Integration)— 5 个

模式 说明 文档
Ambassador 大使 — 简化远程资源管理 ambassador
Anti-Corruption Layer 防腐层 — 确保与遗留系统的完整性 anti-corruption-layer
Gateway 网关 — 简化外部系统集成 gateway
Microservices API Gateway 微服务 API 网关 — 统一端点简化服务访问 microservices-api-gateway
Microservices Log Aggregation 微服务日志聚合 — 集中日志增强监控 microservices-log-aggregation

弹性模式(Resilience)— 5 个

模式 说明 文档
Circuit Breaker 断路器 — 增强系统弹性 circuit-breaker
Queue-Based Load Leveling 基于队列的负载均衡 — 平衡工作负载 queue-based-load-leveling
Retry 重试 — 自适应重试构建容错系统 retry
Saga Saga — 分布式系统中的长事务管理 saga
Tolerant Reader 宽容读取器 — 增强 API 弹性和兼容性 tolerant-reader

消息模式(Messaging)— 4 个

模式 说明 文档
Data Bus 数据总线 — 统一组件通信 data-bus
Event Aggregator 事件聚合器 — 集中管理大型应用中的事件 event-aggregator
Microservices Idempotent Consumer 幂等消费者 — 确保可靠消息处理 microservices-idempotent-consumer
Publish-Subscribe 发布订阅 — 异步通信解耦组件 publish-subscribe

性能优化模式(Performance Optimization)— 3 个

模式 说明 文档
Caching 缓存 — 加速数据访问 caching
Data Locality 数据局部性 — 高效数据管理提升性能 data-locality
Lazy Loading 延迟加载 — 按需初始化对象提升性能 lazy-loading

资源管理模式(Resource Management)— 3 个

模式 说明 文档
RAII 资源获取即初始化 — 安全的资源管理 resource-acquisition-is-initialization
Server Session 服务器会话 — 安全管理的用户会话 server-session
Throttling 节流 — 高需求应用中的资源优化 throttling

惯用法模式(Idiom)— 1 个

模式 说明 文档
Immutable 不可变 — 构建线程安全对象 immutable

服务发现模式(Service Discovery)— 1 个

模式 说明 文档
Microservices Self-Registration 微服务自注册 — Spring Boot + Eureka microservices-self-registration

测试模式(Testing)— 4 个

模式 说明 文档
Arrange/Act/Assert 3A — 测试清晰性和简洁性 arrange-act-assert
Object Mother 对象母亲 — 简化测试对象创建 object-mother
Page Object 页面对象 — 简化 UI 测试维护 page-object
Service Stub 服务桩 — 用桩实现简化测试 service-stub

完整模式列表

Behavioral 行为型模式(40)

Acyclic Visitor · Bytecode · Chain of Responsibility · Client Session · Collecting Parameter · Command · Commander · Context Object · Data Mapper · Delegation · Dirty Flag · Double Buffer · Double Dispatch · Execute Around · Feature Toggle · Filterer · Fluent Interface · Game Loop · Health Check · Identity Map · Interpreter · Iterator · Mediator · Memento · Mute Idiom · Notification · Null Object · Observer · Partial Response · Pipeline · Property · Rate Limiting · Specification · State · Strategy · Subclass Sandbox · Template Method · Template View · Update Method · Visitor

Structural 结构型模式(35)

Abstract Document · Adapter · Bridge · Business Delegate · Component · Composite · Composite Entity · Composite View · Converter · CRTP · DAO Factory · DAO · DTO · Decorator · Domain Model · Dynamic Proxy · Extension Objects · Facade · Flyweight · Marker Interface · Money · Parameter Object · Private Class Data · Proxy · Role Object · Separated Interface · Servant · Service Locator · Session Facade · Spatial Partition · Special Case · Strangler · Twin · Value Object · Virtual Proxy

Architectural 架构模式(25)

Bloc · Clean Architecture · CQRS · Event-Driven Architecture · Event Sourcing · Flux · Front Controller · Hexagonal Architecture · Intercepting Filter · Layered Architecture · Microservices Aggregator · Client-Side UI Composition · Distributed Tracing · MVC · MVI · MVP · MVVM · Monolithic Architecture · Naked Objects · Page Controller · Polling Pub/Sub · Presentation Model · Service Layer · Service to Worker · View Helper

Concurrency 并发模式(22)

Active Object · Actor Model · Async Method Invocation · Backpressure · Balking · Double-Checked Locking · Event-Based Asynchronous · Event Queue · Fan-Out/Fan-In · Guarded Suspension · Half-Sync/Half-Async · Leader Election · Leader-Followers · Lockable Object · Master-Worker · Monitor · Poison Pill · Producer-Consumer · Promise · Reactor · Thread-Pool Executor · Thread-Specific Storage

Creational 创建型模式(14)

Abstract Factory · Builder · Dependency Injection · Factory · Factory Kit · Factory Method · Monostate · Multiton · Object Pool · Prototype · Registry · Singleton · Step Builder · Type Object

Data Access 数据访问模式(12)

Metadata Mapping · Optimistic Offline Lock · Repository · Serialized Entity · Serialized LOB · Sharding · Single Table Inheritance · Table Inheritance · Table Module · Transaction Script · Unit of Work · Version Number

Functional 函数式模式(8)

Callback · Collection Pipeline · Combinator · Currying · Function Composition · MapReduce · Monad · Trampoline

Integration 集成模式(5)

Ambassador · Anti-Corruption Layer · Gateway · Microservices API Gateway · Microservices Log Aggregation

Resilience 弹性模式(5)

Circuit Breaker · Queue-Based Load Leveling · Retry · Saga · Tolerant Reader

Testing 测试模式(4)

Arrange/Act/Assert · Object Mother · Page Object · Service Stub

Messaging 消息模式(4)

Data Bus · Event Aggregator · Idempotent Consumer · Publish-Subscribe

Performance Optimization 性能优化模式(3)

Caching · Data Locality · Lazy Loading

Resource Management 资源管理模式(3)

RAII · Server Session · Throttling

Idiom 惯用法模式(1)

Immutable

Service Discovery 服务发现模式(1)

Self-Registration

Design Principles 设计原则(25)

KISS · YAGNI · DRY · Separation of Concerns · SRP · OCP · LSP · ISP · Composition Over Inheritance · Encapsulate What Changes · Minimise Coupling · Maximise Cohesion · Hide Implementation Details · Law of Demeter · Inversion of Control · Command Query Separation · Avoid Premature Optimization · Code For The Maintainer · Boy-Scout Rule · Robustness Principle · Orthogonality · Curly's Law · Murphy's Law · Brooks's Law · Linus's Law