mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-05-14 12:58:37 +00:00
refactor: Update zh pattern image paths
This commit is contained in:
@@ -259,9 +259,9 @@ Here are two examples of the mock atomic subviews used in the composite:
|
||||
The results are as such:
|
||||
|
||||
1) The user has put their name as `Tammy` in the request parameters and no preferences:
|
||||

|
||||

|
||||
2) The user has put their name as `Johnny` in the request parameters and has a preference for world, business, and science news:
|
||||

|
||||

|
||||
|
||||
The different subviews such as `worldNews.jsp`, `businessNews.jsp`, etc. are included conditionally
|
||||
based on the request parameters.
|
||||
|
||||
@@ -163,7 +163,7 @@ public class Car extends AbstractDocument implements HasModel, HasPrice, HasPart
|
||||
|
||||
## 类图
|
||||
|
||||

|
||||

|
||||
|
||||
## 适用性
|
||||
|
||||
|
||||
@@ -165,7 +165,7 @@ public static void main(String[] args) {
|
||||
|
||||
## 类图
|
||||
|
||||

|
||||

|
||||
|
||||
|
||||
## 适用性
|
||||
|
||||
@@ -119,4 +119,4 @@ public class Orc extends ActiveCreature {
|
||||
|
||||
## 类图
|
||||
|
||||

|
||||

|
||||
|
||||
@@ -120,7 +120,7 @@ public class ConfigureForUnixVisitor implements ZoomVisitor {
|
||||
|
||||
## 类图
|
||||
|
||||

|
||||

|
||||
|
||||
## 适用性
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ captain.row();
|
||||
```
|
||||
|
||||
## 类图
|
||||

|
||||

|
||||
|
||||
|
||||
## 应用
|
||||
|
||||
@@ -92,7 +92,7 @@ curl http://localhost:50004/product
|
||||
|
||||
## 类图
|
||||
|
||||

|
||||

|
||||
|
||||
## 适用性
|
||||
|
||||
|
||||
@@ -164,7 +164,7 @@ Service result: -1
|
||||
|
||||
## 类图
|
||||
|
||||

|
||||

|
||||
|
||||
## 适用性
|
||||
|
||||
|
||||
@@ -120,7 +120,7 @@ public class ApiGateway {
|
||||
```
|
||||
|
||||
## 类图
|
||||

|
||||

|
||||
|
||||
## 适用性
|
||||
|
||||
|
||||
@@ -139,7 +139,7 @@ public static void main(String[] args) throws Exception {
|
||||
|
||||
# 类图
|
||||
|
||||

|
||||

|
||||
|
||||
## 适用性
|
||||
|
||||
|
||||
@@ -108,7 +108,7 @@ public interface DelayProvider {
|
||||
|
||||
## 类图
|
||||
|
||||

|
||||

|
||||
|
||||
## 适用性
|
||||
|
||||
|
||||
@@ -181,7 +181,7 @@ hammer.unwield();
|
||||
|
||||
## 类图
|
||||
|
||||

|
||||

|
||||
|
||||
## 适用性
|
||||
|
||||
|
||||
@@ -111,7 +111,7 @@ var mage = new Hero.Builder(Profession.MAGE, "Riobard").withHairColor(HairColor.
|
||||
|
||||
## 类图
|
||||
|
||||

|
||||

|
||||
|
||||
## 适用性
|
||||
|
||||
|
||||
@@ -129,7 +129,7 @@ public class MobileClient {
|
||||
|
||||
## 类图
|
||||
|
||||

|
||||

|
||||
|
||||
## 相关模式
|
||||
|
||||
|
||||
@@ -211,7 +211,7 @@ public class VirtualMachine {
|
||||
|
||||
## 类图
|
||||
|
||||

|
||||

|
||||
|
||||
## 适用性
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ tags:
|
||||
为了避免昂贵的资源重新获取,方法是在资源使用后不立即释放资源。资源保留其身份,保留在某些快速访问的存储中,并被重新使用,以避免再次获取它们。
|
||||
|
||||
## 类图
|
||||

|
||||

|
||||
|
||||
## 适用性
|
||||
在以下情况下使用缓存模式
|
||||
|
||||
@@ -66,7 +66,7 @@ public final class SimpleTask extends Task {
|
||||
task.executeWith(() -> LOGGER.info("I'm done now."));
|
||||
```
|
||||
## 类图
|
||||

|
||||

|
||||
|
||||
## 适用性
|
||||
使用回调模式当
|
||||
|
||||
@@ -136,7 +136,7 @@ king.makeRequest(new Request(RequestType.COLLECT_TAX, "collect tax")); // Orc so
|
||||
```
|
||||
|
||||
## 类图
|
||||

|
||||

|
||||
|
||||
## 适用性
|
||||
使用责任链模式当
|
||||
|
||||
@@ -37,7 +37,7 @@ remote calls.
|
||||
|
||||
服务架构如下:
|
||||
|
||||

|
||||

|
||||
|
||||
在代码方面,最终用户应用程序是:
|
||||
|
||||
@@ -278,7 +278,7 @@ public class DefaultCircuitBreaker implements CircuitBreaker {
|
||||
|
||||
上述模式如何防止失败? 让我们通过它实现的这个有限状态机来理解。
|
||||
|
||||

|
||||

|
||||
|
||||
- 我们使用某些参数初始化断路器对象:`timeout`、`failureThreshold` 和 `retryTimePeriod`,这有助于确定 API 的弹性。
|
||||
- 最初,我们处于“关闭”状态,没有发生对 API 的远程调用。
|
||||
@@ -288,7 +288,7 @@ public class DefaultCircuitBreaker implements CircuitBreaker {
|
||||
|
||||
## 类图
|
||||
|
||||

|
||||

|
||||
|
||||
## 适用性
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ tags:
|
||||
|
||||
**示例**
|
||||
|
||||

|
||||

|
||||
|
||||
在这个例子中我们使用AWS S3创建一个静态网站,并利用 AWS Cloudfront 在全球范围内分发内容。
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ tags:
|
||||
在函数式编程中,可以通过一系列较小的模块化函数或操作来编排复杂的操作。这一系列函数被称为函数组合。当一个数据集合流经一个函数组合时,它就成为一个集合管道。函数组合和集合管道是函数式编程中经常使用的两种设计模式。
|
||||
|
||||
## 类图
|
||||

|
||||

|
||||
|
||||
## 适用场景
|
||||
在以下场景适用集合管道模式:
|
||||
|
||||
@@ -219,7 +219,7 @@ goblin.printStatus();
|
||||
```
|
||||
|
||||
## 类图
|
||||

|
||||

|
||||
|
||||
## 适用性
|
||||
使用命令模式当你想
|
||||
|
||||
@@ -107,7 +107,7 @@ Arrays.stream(console.getData()).forEach(LOGGER::info);
|
||||
|
||||
## 类图
|
||||
|
||||

|
||||

|
||||
|
||||
## 适用场景
|
||||
|
||||
|
||||
@@ -151,7 +151,7 @@ elfMessage.print(); // Much wind pours from your mouth.
|
||||
|
||||
## 类图
|
||||
|
||||

|
||||

|
||||
|
||||
## 适用性
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ var user = userConverter.convertFromDto(dtoUser);
|
||||
|
||||
## 类图
|
||||
|
||||

|
||||

|
||||
|
||||
## 适用性
|
||||
|
||||
|
||||
@@ -146,7 +146,7 @@ customerDao.getAllCustomers(): java.util.stream.ReferencePipeline$Head@6ec8211c
|
||||
|
||||
## 类图
|
||||
|
||||

|
||||

|
||||
|
||||
## 适用性
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ tags:
|
||||
数据总线模式(译者:实际上,就是 Event-Bus 消息总线模式)允许在一个应用程序的组件之间收发消息/事件,而不需要这些组件相互感知,它们只需要知道所发送/接收的消息/事件的类型即可。
|
||||
|
||||
## 类图
|
||||

|
||||

|
||||
|
||||
## 适用场景
|
||||
可以在以下场景使用数据总线模式:
|
||||
|
||||
@@ -10,7 +10,7 @@ tags:
|
||||
一个用于在持久化对象和数据库之间传输数据的映射器,同时保持它们之间和映射器本身的独立性。
|
||||
|
||||
## 类图
|
||||

|
||||

|
||||
|
||||
## 适用场景
|
||||
数据映射器适用于以下场景:
|
||||
|
||||
@@ -91,7 +91,7 @@ public class CustomerResource {
|
||||
|
||||
## 类图
|
||||
|
||||

|
||||

|
||||
|
||||
## 适用性
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ clubbedTroll.fleeBattle(); // The troll shrieks in horror and runs away!
|
||||
```
|
||||
|
||||
## 类图
|
||||

|
||||

|
||||
|
||||
## 适用性
|
||||
使用装饰者
|
||||
|
||||
@@ -13,7 +13,7 @@ tags:
|
||||
它是一种让对象将某种行为向外部表达,但实际上将实现该行为的责任委托给关联对象的技术。
|
||||
|
||||
## 类图
|
||||

|
||||

|
||||
|
||||
## 适用性
|
||||
使用委托模式以实现以下目的
|
||||
|
||||
@@ -81,7 +81,7 @@ public class AdvancedWizard implements Wizard {
|
||||
|
||||
## 类图
|
||||
|
||||

|
||||

|
||||
|
||||
## 适用性
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ tags:
|
||||
避免昂贵资源的重新获取。资源保留其身份,保留在某些快速访问的存储中,并被重新使用以避免再次获取它们。
|
||||
|
||||
## 类图
|
||||

|
||||

|
||||
|
||||
## 适用性
|
||||
在以下情况下使用脏标志模式
|
||||
|
||||
@@ -10,7 +10,7 @@ tags:
|
||||
通过先测试锁定标准("锁提示")而不实际获取锁的方式来减少获取锁的开销。只有当锁定标准检查表明需要锁定时,才进行实际的锁定逻辑。
|
||||
|
||||
## 类图
|
||||

|
||||

|
||||
|
||||
## 适用场景
|
||||
在以下场景适合使用双重锁检查模式:
|
||||
|
||||
@@ -186,7 +186,7 @@ facade.endDay();
|
||||
```
|
||||
|
||||
## 类图
|
||||

|
||||

|
||||
|
||||
## 适用性
|
||||
使用外观模式当
|
||||
|
||||
@@ -10,7 +10,7 @@ tags:
|
||||
使用分离的构建器和工厂接口来定义一个不可变内容的工厂。
|
||||
|
||||
## 类图
|
||||

|
||||

|
||||
|
||||
## 适用场景
|
||||
工厂套件模式适用于与以下场景:
|
||||
|
||||
@@ -60,7 +60,7 @@ blacksmith.manufactureWeapon(WeaponType.AXE);
|
||||
```
|
||||
|
||||
## 类图
|
||||

|
||||

|
||||
|
||||
## 适用性
|
||||
使用工厂方法模式当
|
||||
|
||||
@@ -106,7 +106,7 @@ This is Ferrari.
|
||||
|
||||
## 类图
|
||||
|
||||

|
||||

|
||||
|
||||
## 适用场景
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ tags:
|
||||
给定一种语言,请定义其语法的表示形式,以及使用该表示形式来解释该语言中的句子的解释器。
|
||||
|
||||
## 类图
|
||||

|
||||

|
||||
|
||||
## 适用性
|
||||
有一种要解释的语言时,请使用解释器模式,并且可以将语言中的语句表示为抽象语法树。解释器模式在以下情况下效果最佳
|
||||
|
||||
@@ -112,7 +112,7 @@ while (itemIterator.hasNext()) {
|
||||
```
|
||||
|
||||
## 类图
|
||||

|
||||

|
||||
|
||||
## 适用性
|
||||
以下情况使用迭代器模式
|
||||
|
||||
@@ -126,7 +126,7 @@ public class Weather {
|
||||
```
|
||||
|
||||
## Class diagram
|
||||

|
||||

|
||||
|
||||
## 应用
|
||||
在下面任何一种情况下都可以使用观察者模式
|
||||
|
||||
@@ -117,7 +117,7 @@ immutableStew.mix(); // Mixing the immutable stew we find: 2 potatoes, 4 carrot
|
||||
|
||||
## 类图
|
||||
|
||||

|
||||

|
||||
|
||||
## 适用性
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ tags:
|
||||
生产者消费者设计模式是一种经典的并发模式,通过将工作与执行工作任务分开来减少生产者与消费者之间的耦合。
|
||||
|
||||
## 类图
|
||||

|
||||

|
||||
|
||||
## 适用性
|
||||
在以下情况下使用生产者消费者
|
||||
|
||||
@@ -120,7 +120,7 @@ Brown wizard is not allowed to enter!
|
||||
|
||||
## 类图
|
||||
|
||||

|
||||

|
||||
|
||||
## 适用性
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ tags:
|
||||
一个分片本身就是一个数据存储(它可以包含许多不同类型的实体的数据),运行在作为存储节点的服务器上。
|
||||
|
||||
## 类图
|
||||

|
||||

|
||||
|
||||
## 适用场景
|
||||
这种设计模式提供了一下的好处:
|
||||
|
||||
@@ -132,7 +132,7 @@ public class Mammoth {
|
||||
```
|
||||
|
||||
## 类图
|
||||

|
||||

|
||||
|
||||
## 适用性
|
||||
|
||||
|
||||
@@ -109,7 +109,7 @@ public class DragonSlayer {
|
||||
```
|
||||
|
||||
## 类图
|
||||

|
||||

|
||||
|
||||
## 应用
|
||||
使用策略模式当
|
||||
|
||||
@@ -116,7 +116,7 @@ public class HalflingThief {
|
||||
```
|
||||
|
||||
## 类图
|
||||

|
||||

|
||||
|
||||
## 适用性
|
||||
|
||||
|
||||
@@ -128,7 +128,7 @@ Exception: Tried to update stale version 0 while actual version is 1
|
||||
|
||||
## 类图
|
||||
|
||||

|
||||

|
||||
|
||||
## 适用性
|
||||
|
||||
|
||||
@@ -198,7 +198,7 @@ Good to see you commander
|
||||
|
||||
## Class diagram
|
||||
|
||||

|
||||

|
||||
|
||||
## 适用性
|
||||
|
||||
|
||||
@@ -161,7 +161,7 @@ public class UserService {
|
||||
|
||||
## Class diagram
|
||||
|
||||

|
||||

|
||||
|
||||
## Applicability
|
||||
|
||||
|
||||
@@ -179,7 +179,7 @@ Here is the console output.
|
||||
|
||||
## Class diagram
|
||||
|
||||

|
||||

|
||||
|
||||
## Applicability
|
||||
|
||||
|
||||
Reference in New Issue
Block a user