[TOC]
---
<!-- # Design Pattern -->

## Design Patterns can be classified into three categories namely
- Creational patterns
- Structural patterns
- Behavioral patterns
> ## 設計模式可分為三類
> - 創建型模式
> - 結構型模式
> - 行為型模式
### [Creational design patterns](https://en.wikipedia.org/wiki/Creational_pattern)
- are design patterns that deal with object creation mechanisms, trying to create objects in a manner suitable to the situation.
- creational patterns consists of five design patterns
> ### 創建型設計模式
> - 處理對象創建機制,試圖以適合情況的方式創建對象。
> - 創建型模式包括五種設計模式
#### [`Abstract Factory`](https://github.com/torokmark/design_patterns_in_typescript/tree/master/abstract_factory)
- which provides an interface for creating related or dependent objects without specifying the objects' concrete classes
> #### 抽象工廠
> - 提供一個接口,用於創建相關或依賴對象,而無需指定對象的具體類別
#### [`Builder`](https://github.com/torokmark/design_patterns_in_typescript/tree/master/builder)
- separate the construction of a complex object from its representation so that the same construction process can create different representations
> #### 建造者
> - 將複雜對象的構建與其表示分離,以便相同的構建過程可以創建不同的表示
#### [`Factory method`](https://github.com/torokmark/design_patterns_in_typescript/tree/master/factory_method)
- centralize creation of an object of a specific type choosing one of several implementations
> #### 工廠方法
> - 集中創建特定類型對象的過程,選擇多個實現之一
#### [`Singleton`](https://github.com/torokmark/design_patterns_in_typescript/tree/master/singleton)
- restrict instantiation of a class to one object
> #### 單例
> - 將類的實例化限制為一個對象
#### [`Prototype`](https://github.com/torokmark/design_patterns_in_typescript/tree/master/prototype)
- used when the type of objects to create is determined by a prototypical instance, which is cloned to produce new objects
> #### 原型
> - 當要創建的對象類型由原型實例確定時,通過克隆原型產生新對象
### [Structural design patterns](https://en.wikipedia.org/wiki/Structural_pattern)
- are design patterns that ease the design by identifying a simple way to realize relationships between entities.
- examples of structural design patters includes the following
> ### 結構型設計模式
> - 通過識別實體之間實現關系的簡單方式來簡化設計的設計模式。
> - 結構型設計模式的示例包括以下內容
#### [`Adapter`](https://github.com/torokmark/design_patterns_in_typescript/tree/master/adapter)
- match interfaces of different classes or 'adapts' one interface for a class into one that a client expects
> #### 適配器
> - 匹配不同類的接口或將一個類的接口“適配”到客戶端期望的接口
#### [`Bridge`](https://github.com/torokmark/design_patterns_in_typescript/tree/master/bridge)
- decouple an abstraction from its implementation so that the two can vary independently
> #### 橋接
> - 將抽象與其實現解耦,以便兩者可以獨立變化
#### [Composite](https://github.com/torokmark/design_patterns_in_typescript/tree/master/composite)
- a tree structure of objects where every object has the same interface
> #### 組合
> - 對象的樹結構,其中每個對象都具有相同的接口
#### [`Decorator`](https://github.com/torokmark/design_patterns_in_typescript/tree/master/decorator)
- add additional functionality to a class at runtime where subclassing would result in an exponential rise of new classes
> #### 裝飾器
> - 在運行時向類添加附加功能,子類化將導致新類的指數增加
#### [`Facade`](https://github.com/torokmark/design_patterns_in_typescript/tree/master/facade)
- create a simplified interface of an existing interface to ease usage for common tasks
> #### 外觀
> - 創建現有接口的簡化接口,以便更容易執行常見任務
#### [`Flyweight`](https://github.com/torokmark/design_patterns_in_typescript/tree/master/flyweight)
- a large quantity of objects share a common properties object to save space
> #### 享元
> - 大量對象共享一個常見屬性對象以節省空間
#### [`Proxy`](https://github.com/torokmark/design_patterns_in_typescript/tree/master/proxy)
- An object representing another object or a class functioning as an interface to something else
> #### 代理
> - 代表另一個對象或作為對其他事物的接口的類
### [Behavioral design patterns](https://en.wikipedia.org/wiki/Behavioral_pattern)
- are design patterns that identify common communication patterns between objects and realize these patterns.
- examples of behavioral design patterns comprise of the following
> ### 行為型設計模式
> - 識別對象之間常見通信模式並實現這些模式的設計模式。
> - 行為型設計模式的示例包括以下內容
#### [`Chain of Responsibility`](https://github.com/torokmark/design_patterns_in_typescript/tree/master/chain_of_responsibility)
- command objects are handled or passed on to other objects by logic-containing processing objects
> #### 責任鏈
> - 由包含邏輯處理對象的命令對象處理或傳遞命令
#### [`Commmand`](https://github.com/torokmark/design_patterns_in_typescript/tree/master/command)
- command objects encapsulate an action and its parameters
> #### 命令
> - 命令對象封裝一個動作及其參數
#### [`Interpreter`](https://github.com/torokmark/design_patterns_in_typescript/tree/master/interpreter)
- a way to include language elements in a program
> #### 解釋器
> - 將語言元素包含到程序中的一種方法
#### [`Iterator`](https://github.com/torokmark/design_patterns_in_typescript/tree/master/iterator)
- iterators are used to access the elements of an aggregate object sequentially without exposing its underlying representation
> #### 叠代器
> - 用於按順序訪問聚合對象的元素,而不公開其底層表示
#### [`Mediator`](https://github.com/torokmark/design_patterns_in_typescript/tree/master/mediator)
- provides a unified interface to a set of interfaces in a subsystem
> #### 中介者
> - 為子系統中的一組接口提供一個統一的接口
#### [`Memento`](https://github.com/torokmark/design_patterns_in_typescript/tree/master/memento)
- provides the ability to restore an object to its previous state (rollback)
> #### 備忘錄
> - 提供將對象恢覆到其先前狀態的能力(回滾)
#### [`Observer`](https://github.com/torokmark/design_patterns_in_typescript/tree/master/observer)
- objects register to observe an event that may be raised by another object
> #### 觀察者
> - 對象注冊以觀察另一個對象可能引發的事件
#### [`State`](https://github.com/torokmark/design_patterns_in_typescript/tree/master/state)
- a clean way for an object to partially change its type at runtime
> #### 狀態
> - 對象以一種幹凈的方式在運行時部分更改其類型
#### [`Strategy`](https://github.com/torokmark/design_patterns_in_typescript/tree/master/strategy)
- algorithms can be selected on the fly
> #### 策略
> - 可以動態選擇算法
#### [`Template method`](https://github.com/torokmark/design_patterns_in_typescript/tree/master/template_method)
- defer the exact steps of an algorithm to a subclass
> #### 模板方法
> - 將算法的確切步驟推遲到子類
#### [`Visitor`](https://github.com/torokmark/design_patterns_in_typescript/tree/master/visitor)
- a way to separate an algorithm from an object
> #### 訪問者
> - 將算法與對象分離
---
##### 參考
> - [C#](https://github.com/Marusyk/DesignPatterns)
> - [Typescript](https://github.com/torokmark/design_patterns_in_typescript)
> - **[Guru Design Pattern](https://refactoring.guru/design-patterns/typescript)**