mirror of
https://github.com/Estom/notes.git
synced 2026-04-05 03:48:56 +08:00
设计模式
This commit is contained in:
@@ -1,12 +1,15 @@
|
||||
## 计划
|
||||
|
||||
- [ ] 设计模式复习(网站)
|
||||
- [ ] 设计模式复习
|
||||
- [ ] vscode C++集成开发环境
|
||||
- [ ] cmake/vs 项目重构
|
||||
- [ ] 制定四月份论文阅读计划
|
||||
|
||||
|
||||
- TensorFlow之前的计划
|
||||
- pytorch之前的计划
|
||||
|
||||
|
||||
- [ ] 制定四月份论文阅读计划
|
||||
|
||||
## 收获
|
||||
|
||||
##
|
||||
268
设计模式/0 设计模式概述.md
268
设计模式/0 设计模式概述.md
@@ -1,134 +1,140 @@
|
||||
<!-- GFM-TOC -->
|
||||
* [一、概述](#一概述)
|
||||
* [二、创建型](#二创建型)
|
||||
* [1. 单例(Singleton)](#1-单例singleton)
|
||||
* [Intent](#intent)
|
||||
* [Class Diagram](#class-diagram)
|
||||
* [Implementation](#implementation)
|
||||
* [Examples](#examples)
|
||||
* [JDK](#jdk)
|
||||
* [2. 简单工厂(Simple Factory)](#2-简单工厂simple-factory)
|
||||
* [Intent](#intent)
|
||||
* [Class Diagram](#class-diagram)
|
||||
* [Implementation](#implementation)
|
||||
* [3. 工厂方法(Factory Method)](#3-工厂方法factory-method)
|
||||
* [Intent](#intent)
|
||||
* [Class Diagram](#class-diagram)
|
||||
* [Implementation](#implementation)
|
||||
* [JDK](#jdk)
|
||||
* [4. 抽象工厂(Abstract Factory)](#4-抽象工厂abstract-factory)
|
||||
* [Intent](#intent)
|
||||
* [Class Diagram](#class-diagram)
|
||||
* [Implementation](#implementation)
|
||||
* [JDK](#jdk)
|
||||
* [5. 生成器(Builder)](#5-生成器builder)
|
||||
* [Intent](#intent)
|
||||
* [Class Diagram](#class-diagram)
|
||||
* [Implementation](#implementation)
|
||||
* [JDK](#jdk)
|
||||
* [6. 原型模式(Prototype)](#6-原型模式prototype)
|
||||
* [Intent](#intent)
|
||||
* [Class Diagram](#class-diagram)
|
||||
* [Implementation](#implementation)
|
||||
* [JDK](#jdk)
|
||||
* [三、行为型](#三行为型)
|
||||
* [1. 责任链(Chain Of Responsibility)](#1-责任链chain-of-responsibility)
|
||||
* [Intent](#intent)
|
||||
* [Class Diagram](#class-diagram)
|
||||
* [Implementation](#implementation)
|
||||
* [JDK](#jdk)
|
||||
* [2. 命令(Command)](#2-命令command)
|
||||
* [Intent](#intent)
|
||||
* [Class Diagram](#class-diagram)
|
||||
* [Implementation](#implementation)
|
||||
* [JDK](#jdk)
|
||||
* [3. 解释器(Interpreter)](#3-解释器interpreter)
|
||||
* [Intent](#intent)
|
||||
* [Class Diagram](#class-diagram)
|
||||
* [Implementation](#implementation)
|
||||
* [JDK](#jdk)
|
||||
* [4. 迭代器(Iterator)](#4-迭代器iterator)
|
||||
* [Intent](#intent)
|
||||
* [Class Diagram](#class-diagram)
|
||||
* [Implementation](#implementation)
|
||||
* [JDK](#jdk)
|
||||
* [5. 中介者(Mediator)](#5-中介者mediator)
|
||||
* [Intent](#intent)
|
||||
* [Class Diagram](#class-diagram)
|
||||
* [Implementation](#implementation)
|
||||
* [JDK](#jdk)
|
||||
* [6. 备忘录(Memento)](#6-备忘录memento)
|
||||
* [Intent](#intent)
|
||||
* [Class Diagram](#class-diagram)
|
||||
* [Implementation](#implementation)
|
||||
* [JDK](#jdk)
|
||||
* [7. 观察者(Observer)](#7-观察者observer)
|
||||
* [Intent](#intent)
|
||||
* [Class Diagram](#class-diagram)
|
||||
* [Implementation](#implementation)
|
||||
* [JDK](#jdk)
|
||||
* [8. 状态(State)](#8-状态state)
|
||||
* [Intent](#intent)
|
||||
* [Class Diagram](#class-diagram)
|
||||
* [Implementation](#implementation)
|
||||
* [9. 策略(Strategy)](#9-策略strategy)
|
||||
* [Intent](#intent)
|
||||
* [Class Diagram](#class-diagram)
|
||||
* [与状态模式的比较](#与状态模式的比较)
|
||||
* [Implementation](#implementation)
|
||||
* [JDK](#jdk)
|
||||
* [10. 模板方法(Template Method)](#10-模板方法template-method)
|
||||
* [Intent](#intent)
|
||||
* [Class Diagram](#class-diagram)
|
||||
* [Implementation](#implementation)
|
||||
* [JDK](#jdk)
|
||||
* [11. 访问者(Visitor)](#11-访问者visitor)
|
||||
* [Intent](#intent)
|
||||
* [Class Diagram](#class-diagram)
|
||||
* [Implementation](#implementation)
|
||||
* [JDK](#jdk)
|
||||
* [12. 空对象(Null)](#12-空对象null)
|
||||
* [Intent](#intent)
|
||||
* [Class Diagram](#class-diagram)
|
||||
* [Implementation](#implementation)
|
||||
* [四、结构型](#四结构型)
|
||||
* [1. 适配器(Adapter)](#1-适配器adapter)
|
||||
* [Intent](#intent)
|
||||
* [Class Diagram](#class-diagram)
|
||||
* [Implementation](#implementation)
|
||||
* [JDK](#jdk)
|
||||
* [2. 桥接(Bridge)](#2-桥接bridge)
|
||||
* [Intent](#intent)
|
||||
* [Class Diagram](#class-diagram)
|
||||
* [Implementation](#implementation)
|
||||
* [JDK](#jdk)
|
||||
* [3. 组合(Composite)](#3-组合composite)
|
||||
* [Intent](#intent)
|
||||
* [Class Diagram](#class-diagram)
|
||||
* [Implementation](#implementation)
|
||||
* [JDK](#jdk)
|
||||
* [4. 装饰(Decorator)](#4-装饰decorator)
|
||||
* [Intent](#intent)
|
||||
* [Class Diagram](#class-diagram)
|
||||
* [Implementation](#implementation)
|
||||
* [设计原则](#设计原则)
|
||||
* [JDK](#jdk)
|
||||
* [5. 外观(Facade)](#5-外观facade)
|
||||
* [Intent](#intent)
|
||||
* [Class Diagram](#class-diagram)
|
||||
* [Implementation](#implementation)
|
||||
* [设计原则](#设计原则)
|
||||
* [6. 享元(Flyweight)](#6-享元flyweight)
|
||||
* [Intent](#intent)
|
||||
* [Class Diagram](#class-diagram)
|
||||
* [Implementation](#implementation)
|
||||
* [JDK](#jdk)
|
||||
* [7. 代理(Proxy)](#7-代理proxy)
|
||||
* [Intent](#intent)
|
||||
* [Class Diagram](#class-diagram)
|
||||
* [Implementation](#implementation)
|
||||
* [JDK](#jdk)
|
||||
* [参考资料](#参考资料)
|
||||
- [一、概述](#一概述)
|
||||
- [二、创建型](#二创建型)
|
||||
- [1. 单例(Singleton)](#1-单例singleton)
|
||||
- [Intent](#intent)
|
||||
- [Class Diagram](#class-diagram)
|
||||
- [Implementation](#implementation)
|
||||
- [Ⅰ 懒汉式-线程不安全](#ⅰ-懒汉式-线程不安全)
|
||||
- [Ⅱ 饿汉式-线程安全](#ⅱ-饿汉式-线程安全)
|
||||
- [Ⅲ 懒汉式-线程安全](#ⅲ-懒汉式-线程安全)
|
||||
- [Ⅳ 双重校验锁-线程安全](#ⅳ-双重校验锁-线程安全)
|
||||
- [Ⅴ 静态内部类实现](#ⅴ-静态内部类实现)
|
||||
- [Ⅵ 枚举实现](#ⅵ-枚举实现)
|
||||
- [Examples](#examples)
|
||||
- [JDK](#jdk)
|
||||
- [2. 简单工厂(Simple Factory)](#2-简单工厂simple-factory)
|
||||
- [Intent](#intent-1)
|
||||
- [Class Diagram](#class-diagram-1)
|
||||
- [Implementation](#implementation-1)
|
||||
- [3. 工厂方法(Factory Method)](#3-工厂方法factory-method)
|
||||
- [Intent](#intent-2)
|
||||
- [Class Diagram](#class-diagram-2)
|
||||
- [Implementation](#implementation-2)
|
||||
- [JDK](#jdk-1)
|
||||
- [4. 抽象工厂(Abstract Factory)](#4-抽象工厂abstract-factory)
|
||||
- [Intent](#intent-3)
|
||||
- [Class Diagram](#class-diagram-3)
|
||||
- [Implementation](#implementation-3)
|
||||
- [JDK](#jdk-2)
|
||||
- [5. 生成器(Builder)](#5-生成器builder)
|
||||
- [Intent](#intent-4)
|
||||
- [Class Diagram](#class-diagram-4)
|
||||
- [Implementation](#implementation-4)
|
||||
- [JDK](#jdk-3)
|
||||
- [6. 原型模式(Prototype)](#6-原型模式prototype)
|
||||
- [Intent](#intent-5)
|
||||
- [Class Diagram](#class-diagram-5)
|
||||
- [Implementation](#implementation-5)
|
||||
- [JDK](#jdk-4)
|
||||
- [三、行为型](#三行为型)
|
||||
- [1. 责任链(Chain Of Responsibility)](#1-责任链chain-of-responsibility)
|
||||
- [Intent](#intent-6)
|
||||
- [Class Diagram](#class-diagram-6)
|
||||
- [Implementation](#implementation-6)
|
||||
- [JDK](#jdk-5)
|
||||
- [2. 命令(Command)](#2-命令command)
|
||||
- [Intent](#intent-7)
|
||||
- [Class Diagram](#class-diagram-7)
|
||||
- [Implementation](#implementation-7)
|
||||
- [JDK](#jdk-6)
|
||||
- [3. 解释器(Interpreter)](#3-解释器interpreter)
|
||||
- [Intent](#intent-8)
|
||||
- [Class Diagram](#class-diagram-8)
|
||||
- [Implementation](#implementation-8)
|
||||
- [JDK](#jdk-7)
|
||||
- [4. 迭代器(Iterator)](#4-迭代器iterator)
|
||||
- [Intent](#intent-9)
|
||||
- [Class Diagram](#class-diagram-9)
|
||||
- [Implementation](#implementation-9)
|
||||
- [JDK](#jdk-8)
|
||||
- [5. 中介者(Mediator)](#5-中介者mediator)
|
||||
- [Intent](#intent-10)
|
||||
- [Class Diagram](#class-diagram-10)
|
||||
- [Implementation](#implementation-10)
|
||||
- [JDK](#jdk-9)
|
||||
- [6. 备忘录(Memento)](#6-备忘录memento)
|
||||
- [Intent](#intent-11)
|
||||
- [Class Diagram](#class-diagram-11)
|
||||
- [Implementation](#implementation-11)
|
||||
- [JDK](#jdk-10)
|
||||
- [7. 观察者(Observer)](#7-观察者observer)
|
||||
- [Intent](#intent-12)
|
||||
- [Class Diagram](#class-diagram-12)
|
||||
- [Implementation](#implementation-12)
|
||||
- [JDK](#jdk-11)
|
||||
- [8. 状态(State)](#8-状态state)
|
||||
- [Intent](#intent-13)
|
||||
- [Class Diagram](#class-diagram-13)
|
||||
- [Implementation](#implementation-13)
|
||||
- [9. 策略(Strategy)](#9-策略strategy)
|
||||
- [Intent](#intent-14)
|
||||
- [Class Diagram](#class-diagram-14)
|
||||
- [与状态模式的比较](#与状态模式的比较)
|
||||
- [Implementation](#implementation-14)
|
||||
- [JDK](#jdk-12)
|
||||
- [10. 模板方法(Template Method)](#10-模板方法template-method)
|
||||
- [Intent](#intent-15)
|
||||
- [Class Diagram](#class-diagram-15)
|
||||
- [Implementation](#implementation-15)
|
||||
- [JDK](#jdk-13)
|
||||
- [11. 访问者(Visitor)](#11-访问者visitor)
|
||||
- [Intent](#intent-16)
|
||||
- [Class Diagram](#class-diagram-16)
|
||||
- [Implementation](#implementation-16)
|
||||
- [JDK](#jdk-14)
|
||||
- [12. 空对象(Null)](#12-空对象null)
|
||||
- [Intent](#intent-17)
|
||||
- [Class Diagram](#class-diagram-17)
|
||||
- [Implementation](#implementation-17)
|
||||
- [四、结构型](#四结构型)
|
||||
- [1. 适配器(Adapter)](#1-适配器adapter)
|
||||
- [Intent](#intent-18)
|
||||
- [Class Diagram](#class-diagram-18)
|
||||
- [Implementation](#implementation-18)
|
||||
- [JDK](#jdk-15)
|
||||
- [2. 桥接(Bridge)](#2-桥接bridge)
|
||||
- [Intent](#intent-19)
|
||||
- [Class Diagram](#class-diagram-19)
|
||||
- [Implementation](#implementation-19)
|
||||
- [JDK](#jdk-16)
|
||||
- [3. 组合(Composite)](#3-组合composite)
|
||||
- [Intent](#intent-20)
|
||||
- [Class Diagram](#class-diagram-20)
|
||||
- [Implementation](#implementation-20)
|
||||
- [JDK](#jdk-17)
|
||||
- [4. 装饰(Decorator)](#4-装饰decorator)
|
||||
- [Intent](#intent-21)
|
||||
- [Class Diagram](#class-diagram-21)
|
||||
- [Implementation](#implementation-21)
|
||||
- [设计原则](#设计原则)
|
||||
- [JDK](#jdk-18)
|
||||
- [5. 外观(Facade)](#5-外观facade)
|
||||
- [Intent](#intent-22)
|
||||
- [Class Diagram](#class-diagram-22)
|
||||
- [Implementation](#implementation-22)
|
||||
- [设计原则](#设计原则-1)
|
||||
- [6. 享元(Flyweight)](#6-享元flyweight)
|
||||
- [Intent](#intent-23)
|
||||
- [Class Diagram](#class-diagram-23)
|
||||
- [Implementation](#implementation-23)
|
||||
- [JDK](#jdk-19)
|
||||
- [7. 代理(Proxy)](#7-代理proxy)
|
||||
- [Intent](#intent-24)
|
||||
- [Class Diagram](#class-diagram-24)
|
||||
- [Implementation](#implementation-24)
|
||||
- [JDK](#jdk-20)
|
||||
- [参考资料](#参考资料)
|
||||
<!-- GFM-TOC -->
|
||||
|
||||
|
||||
@@ -152,7 +158,7 @@
|
||||
|
||||
私有构造函数保证了不能通过构造函数来创建对象实例,只能通过公有静态函数返回唯一的私有静态变量。
|
||||
|
||||
<div align="center"> <img src="https://cs-notes-1256109796.cos.ap-guangzhou.myqcloud.com/eca1f422-8381-409b-ad04-98ef39ae38ba.png"/> </div><br>
|
||||

|
||||
|
||||
### Implementation
|
||||
|
||||
|
||||
BIN
设计模式/image/2021-04-10-16-48-05.png
Normal file
BIN
设计模式/image/2021-04-10-16-48-05.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 16 KiB |
18
设计模式/refactor/重构规划书.md
Normal file
18
设计模式/refactor/重构规划书.md
Normal file
@@ -0,0 +1,18 @@
|
||||
# SimuRosot项目重构规划书
|
||||
|
||||
## 1 重构的目标
|
||||
|
||||
- 增强可读性(**自动生成项目的说明文档**)
|
||||
- 增强可扩展性,降低模块的耦合和代码的冗余。面向对象、接口。
|
||||
- 增强可修改性,方便代码进行修改和扩展。
|
||||
|
||||
## 2 重构的流程
|
||||
|
||||
- [ ] 重读设计模式和架构设计。使用更好的架构和模块设计方案。(给出一个**架构设计说明书**)。
|
||||
- [ ] 了解重构工具和重构的方法。熟练掌握C++项目重构过程。
|
||||
- [ ] 熟读源代码,对架构设计说明书进行增删修改。完成最终的架构设计说明书。
|
||||
- [ ] 使用vs对**项目**架构进行重构。
|
||||
|
||||
> 方案1:主要还是重新设计项目,把项目内的其他代码赋值黏贴出来。让它成为一个新的能够运行的小项目。
|
||||
>
|
||||
> 方案2:重新设计项目,然后在原有的代码上进行重构。
|
||||
Reference in New Issue
Block a user