From 20b48391b39121b3742514ea6cbbe4f5eda48753 Mon Sep 17 00:00:00 2001 From: Edward Date: Tue, 5 May 2020 22:04:16 +0800 Subject: [PATCH] regular state pattern --- README.md | 2 +- behavior/10_state/README.md | 3 +++ behavior/{16_state => 10_state}/state.go | 0 behavior/{16_state => 10_state}/state_test.go | 0 behavior/16_state/README.md | 3 --- 5 files changed, 4 insertions(+), 4 deletions(-) create mode 100644 behavior/10_state/README.md rename behavior/{16_state => 10_state}/state.go (100%) rename behavior/{16_state => 10_state}/state_test.go (100%) delete mode 100644 behavior/16_state/README.md diff --git a/README.md b/README.md index af55497..cabe969 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,7 @@ ## 行为型模式 Behavior Patterns ++ [x] [备忘录模式(Memento)](./behavior/09_memento) + [x] [中介者模式(Mediator)](./behavior/01_mediator) + [x] [闭包选项模式(Function Option)](./behavior/02_option) + [x] [观察者模式(Observer)](./behavior/03_observer) @@ -26,7 +27,6 @@ + [x] [模板方法模式(Template Method)](./behavior/05_template_method) + [x] [策略模式(Strategy)](./behavior/12_strategy) + [ ] [WIP][状态模式(State)](./behavior/behavior16_state) -+ [ ] [备忘录模式(Memento)](./behavior/09_memento) + [x] [访问者模式(Visitor)](./behavior/07_visitor) + [x] [解释器模式(Interpreter)](./behavior/08_interpreter) + [x] [职责链模式(Chain of Responsibility)](./behavior/06_chain_of_responsibility) diff --git a/behavior/10_state/README.md b/behavior/10_state/README.md new file mode 100644 index 0000000..11525ca --- /dev/null +++ b/behavior/10_state/README.md @@ -0,0 +1,3 @@ +# 状态模式 + +状态模式的目的就是设计一个状态机,用状态的改变/流转驱动行为变化,前提是需要知道所有的状态,否则,该模式有益于根据已知状态扩展行为。 diff --git a/behavior/16_state/state.go b/behavior/10_state/state.go similarity index 100% rename from behavior/16_state/state.go rename to behavior/10_state/state.go diff --git a/behavior/16_state/state_test.go b/behavior/10_state/state_test.go similarity index 100% rename from behavior/16_state/state_test.go rename to behavior/10_state/state_test.go diff --git a/behavior/16_state/README.md b/behavior/16_state/README.md deleted file mode 100644 index fae5501..0000000 --- a/behavior/16_state/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# 状态模式 - -状态模式的意图是将状态和行为分类,go语言自身的结构和接口实现就是一个状态模式,因为结构本身往往是有状态的,表示行为的接口可以组合到结构上,形成完整的功能单元.