Fix words.

This commit is contained in:
Lolipop 2021-05-22 21:56:19 +08:00
parent 9a4c3ed995
commit 899b7e620c
6 changed files with 49 additions and 40 deletions

View File

@ -45,13 +45,13 @@
### 🐢 在开始之前 / Before you start
- 所有的设计模式示例都基于 JavaScript 的 [ES6](https://github.com/lukehoban/es6features) 规范实现。
- 由于 JavaScript 中不存在实现接口的说法,因此我们在示例里使用了隐式接口的方式,这意味着只有一个类具有一个接口应当有的属性和方法,这个类就被认为实现了这个接口。为了让您更容易分辨当前正在使用的接口,我们在每个示例中都添加了注释信息。
- 由于 JavaScript 中不存在实现接口的说法,因此我们在代码示例中使用了隐式接口,这意味着只有一个类具有一个接口应当有的属性和方法,这个类就被认为实现了这个接口。为了让您更容易分辨当前正在使用的接口,我们在每个示例中都添加了注释信息。
### 🛎️ 设计模式的类型 / Types of Design Patterns
* [创建型 / Creational](#creational-design-patterns)
* [结构型 / Structural](#structural-design-patterns)
* [行为型 / Behavioral](#behavioral-design-patterns)
* [创建型](#%EF%B8%8F-创建型设计模式--creational-design-patterns)
* [结构型](#-结构型设计模式--structural-design-patterns)
* [行为型](#-行为型设计模式--behavioral-design-patterns)
## 🏗️ 创建型设计模式 / Creational Design Patterns
@ -61,12 +61,12 @@ In plain words
Wikipedia says
> In software engineering, creational design patterns are design patterns that deal with object creation mechanisms, trying to create objects in a manner suitable to the situation. The basic form of object creation could result in design problems or added complexity to the design. Creational design patterns solve this problem by somehow controlling this object creation.
* [Simple Factory](#-simple-factory)
* [Factory Method](#-factory-method)
* [Abstract Factory](#-abstract-factory)
* [Builder](#-builder)
* [Prototype](#-prototype)
* [Singleton](#-singleton)
* [简单工厂模式](#-简单工厂模式--simple-factory)
* [工厂方法模式](#-工厂方法模式--factory-method)
* [抽象工厂模式](#-抽象工厂模式--abstract-factory)
* [生成器模式](#-生成器模式--builder)
* [原型模式](#-原型模式--prototype)
* [单例模式](#-单例模式--singleton)
### 🏠 简单工厂模式 / Simple Factory
@ -486,7 +486,9 @@ class Sheep
}
}
```
Then it can be cloned like below
```php
$original = new Sheep('Jolly');
echo $original->getName(); // Jolly
@ -552,13 +554,13 @@ In plain words
Wikipedia says
> In software engineering, structural design patterns are design patterns that ease the design by identifying a simple way to realize relationships between entities.
* [Adapter](#-adapter)
* [Bridge](#-bridge)
* [Composite](#-composite)
* [Decorator](#-decorator)
* [Facade](#-facade)
* [Flyweight](#-flyweight)
* [Proxy](#-proxy)
* [适配器模式](#-适配器模式--adapter)
* [桥接模式](#-桥接模式--bridge)
* [组合模式](#-组合模式--composite)
* [装饰器模式](#-装饰器模式--decorator)
* [门面模式](#-门面模式--facade)
* [享元模式](#-享元模式--flyweight)
* [代理模式](#-代理模式--proxy)
### 🔌 适配器模式 / Adapter
@ -1181,16 +1183,16 @@ In plain words
Wikipedia says
> In software engineering, behavioral design patterns are design patterns that identify common communication patterns between objects and realize these patterns. By doing so, these patterns increase flexibility in carrying out this communication.
* [Chain of Responsibility](#-chain-of-responsibility)
* [Command](#-command)
* [Iterator](#-iterator)
* [Mediator](#-mediator)
* [Memento](#-memento)
* [Observer](#-observer)
* [Visitor](#-visitor)
* [Strategy](#-strategy)
* [State](#-state)
* [Template Method](#-template-method)
* [责任链模式](#-责任链模式--chain-of-responsibility)
* [命令模式](#-命令模式--command)
* [迭代器模式](#-迭代器模式--iterator)
* [中介者模式](#-中介者模式--mediator)
* [备忘录模式](#-备忘录模式--memento)
* [观察者模式](#-观察者模式--observer)
* [访问者模式](#-访问者模式--visitor)
* [策略模式](#-策略模式--strategy)
* [状态模式](#-状态模式--state)
* [模板方法模式](#-模板方法模式--template-method)
### 🔗 责任链模式 / Chain of Responsibility
@ -1451,17 +1453,17 @@ stationList.removeStation(new RadioStation(89)) // Will remove station 89
### 👽 中介者模式 / Mediator
Real world example
> A general example would be when you talk to someone on your mobile phone, there is a network provider sitting between you and them and your conversation goes through it instead of being directly sent. In this case network provider is mediator.
> A general example would be when you talk to someone on your mobile phone, there is a network provider sitting between you and them and your conversation goes through it instead of being directly sent. In this case network provider is mediator.
In plain words
> Mediator pattern adds a third party object (called mediator) to control the interaction between two objects (called colleagues). It helps reduce the coupling between the classes communicating with each other. Because now they don't need to have the knowledge of each other's implementation.
> Mediator pattern adds a third party object (called mediator) to control the interaction between two objects (called colleagues). It helps reduce the coupling between the classes communicating with each other. Because now they don't need to have the knowledge of each other's implementation.
Wikipedia says
> In software engineering, the mediator pattern defines an object that encapsulates how a set of objects interact. This pattern is considered to be a behavioral pattern due to the way it can alter the program's running behavior.
**Programmatic Example**
Here is the simplest example of a chat room (i.e. mediator) with users (i.e. colleagues) sending messages to each other.
Here is the simplest example of a chat room (i.e. mediator) with users (i.e. colleagues) sending messages to each other.
First of all, we have the mediator i.e. the chat room
@ -1515,7 +1517,7 @@ jane.send('Hey!')
### 💾 备忘录模式 / Memento
Real world example
> Take the example of calculator (i.e. originator), where whenever you perform some calculation the last calculation is saved in memory (i.e. memento) so that you can get back to it and maybe get it restored using some action buttons (i.e. caretaker).
> Take the example of calculator (i.e. originator), where whenever you perform some calculation the last calculation is saved in memory (i.e. memento) so that you can get back to it and maybe get it restored using some action buttons (i.e. caretaker).
In plain words
> Memento pattern is about capturing and storing the current state of an object in a manner that it can be restored later on in a smooth manner.
@ -1996,7 +1998,7 @@ iosBuilder.build()
## 🚦 尾声 / Wrap Up Folks
到这里教程的正文内容就结束了。我会持续改进这篇教程,也许您以后想要重新访问这个仓库来查看最新的内容,不妨点一个关注以及星标。对了,我计划撰写同样风格的教程,探讨软件体系架构模式的内容,希望您继续关注。
到这里教程的正文内容就结束了。我会持续改进这篇教程,也许您以后想要重新访问这个仓库来查看最新的内容,不妨点一个关注以及星标。对了,我计划撰写同样风格的软件体系架构教程,希望您继续关注。
## 👬 参与贡献 / Contribution

View File

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

View File

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

View File

@ -1,6 +1,6 @@
# Design Patterns for Humans ZH - VuePress
通过 VuePress 部署静态网页
通过 VuePress 部署本项目
## 安装依赖
@ -31,3 +31,10 @@ yarn build
```
默认存放路径为 `./docs/.vuepress/dist`
## 待完成清单
- [ ] 添加多编程语言支持。
- [ ] PHP
- [ ] Python
- [ ] ...

View File

@ -41,7 +41,7 @@
### 🐢 在开始之前 / Before you start
- 所有的设计模式示例都基于 JavaScript 的 [ES6](https://github.com/lukehoban/es6features) 规范实现。
- 由于 JavaScript 中不存在实现接口的说法,因此我们在示例里使用了隐式接口的方式,这意味着只有一个类具有一个接口应当有的属性和方法,这个类就被认为实现了这个接口。为了让您更容易分辨当前正在使用的接口,我们在每个示例中都添加了注释信息。
- 由于 JavaScript 中不存在实现接口的说法,因此我们在代码示例中使用了隐式接口,这意味着只有一个类具有一个接口应当有的属性和方法,这个类就被认为实现了这个接口。为了让您更容易分辨当前正在使用的接口,我们在每个示例中都添加了注释信息。
## 🏗️ 创建型设计模式 / Creational Design Patterns
@ -1415,19 +1415,19 @@ stationList.removeStation(new RadioStation(89)) // Will remove station 89
### 👽 中介者模式 / Mediator
Real world example
> A general example would be when you talk to someone on your mobile phone, there is a network provider sitting between you and them and your conversation goes through it instead of being directly sent. In this case network provider is mediator.
> A general example would be when you talk to someone on your mobile phone, there is a network provider sitting between you and them and your conversation goes through it instead of being directly sent. In this case network provider is mediator.
In plain words
> Mediator pattern adds a third party object (called mediator) to control the interaction between two objects (called colleagues). It helps reduce the coupling between the classes communicating with each other. Because now they don't need to have the knowledge of each other's implementation.
> Mediator pattern adds a third party object (called mediator) to control the interaction between two objects (called colleagues). It helps reduce the coupling between the classes communicating with each other. Because now they don't need to have the knowledge of each other's implementation.
Wikipedia says
> In software engineering, the mediator pattern defines an object that encapsulates how a set of objects interact. This pattern is considered to be a behavioral pattern due to the way it can alter the program's running behavior.
**Programmatic Example**
Here is the simplest example of a chat room (i.e. mediator) with users (i.e. colleagues) sending messages to each other.
Here is the simplest example of a chat room (i.e. mediator) with users (i.e. colleagues) sending messages to each other.
First of all, we have the mediator i.e. the chat room
First of all, we have the mediator i.e. the chat room
```js
// Mediator
@ -1479,7 +1479,7 @@ jane.send('Hey!')
### 💾 备忘录模式 / Memento
Real world example
> Take the example of calculator (i.e. originator), where whenever you perform some calculation the last calculation is saved in memory (i.e. memento) so that you can get back to it and maybe get it restored using some action buttons (i.e. caretaker).
> Take the example of calculator (i.e. originator), where whenever you perform some calculation the last calculation is saved in memory (i.e. memento) so that you can get back to it and maybe get it restored using some action buttons (i.e. caretaker).
In plain words
> Memento pattern is about capturing and storing the current state of an object in a manner that it can be restored later on in a smooth manner.
@ -1960,7 +1960,7 @@ iosBuilder.build()
## 🚦 尾声 / Wrap Up Folks
到这里教程的正文内容就结束了。我会持续改进这篇教程,也许您以后想要重新访问这个仓库来查看最新的内容,不妨点一个关注以及星标。对了,我计划撰写同样风格的教程,探讨软件体系架构模式的内容,希望您继续关注。
到这里教程的正文内容就结束了。我会持续改进这篇教程,也许您以后想要重新访问这个仓库来查看最新的内容,不妨点一个关注以及星标。对了,我计划撰写同样风格的软件体系架构教程,希望您继续关注。
## 👬 参与贡献 / Contribution