-
Notifications
You must be signed in to change notification settings - Fork 57
Add comprehensive UML class diagrams for all design patterns with multilingual documentation #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
WeihanLi
merged 7 commits into
main
from
copilot/fix-dfbf5614-fdca-4344-88fb-832d7cfe77c3
Sep 27, 2025
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
79d0531
Initial plan
Copilot 3e2c51b
Add UML diagrams for initial design patterns
Copilot e4c530a
Add comprehensive UML diagrams for design patterns
Copilot 101882f
Complete UML diagram collection - add Interpreter pattern
Copilot f0cd6e6
Merge branch 'main' into copilot/fix-dfbf5614-fdca-4344-88fb-832d7cfe…
WeihanLi cbca0f2
Add VS Code extension info and Chinese README translation
Copilot 8bf90a0
Fix behavioral patterns count in English README (11 not 12)
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| # UML Diagrams for Design Patterns | ||
|
|
||
| This folder contains UML diagrams for all design patterns implemented in this repository. | ||
|
|
||
| ## Structure | ||
|
|
||
| - `creational/` - UML diagrams for creational patterns | ||
| - `structural/` - UML diagrams for structural patterns | ||
| - `behavioral/` - UML diagrams for behavioral patterns | ||
|
|
||
| ## Format | ||
|
|
||
| All diagrams are provided in PlantUML format (.puml files) which can be rendered as images using various tools. | ||
|
|
||
| ## Usage | ||
|
|
||
| To render these diagrams: | ||
| 1. **Online**: Use online renderer at http://www.plantuml.com/plantuml/uml/ | ||
| 2. **Local Installation**: Install PlantUML locally | ||
| 3. **VS Code**: Install the PlantUML extension for VS Code for inline preview and rendering | ||
| 4. **IDE Plugins**: Use PlantUML plugins available for IntelliJ IDEA, Eclipse, and other IDEs | ||
|
|
||
| Open the .puml files and render them as PNG/SVG images | ||
|
|
||
| ## Patterns Included | ||
|
|
||
| ### Creational Patterns (6) | ||
| - Simple Factory Pattern | ||
| - Abstract Factory Pattern | ||
| - Factory Method Pattern | ||
| - Builder Pattern | ||
| - Prototype Pattern | ||
| - Singleton Pattern | ||
|
|
||
| ### Structural Patterns (7) | ||
| - Adapter Pattern | ||
| - Bridge Pattern | ||
| - Composite Pattern | ||
| - Decorator Pattern | ||
| - Facade Pattern | ||
| - Flyweight Pattern | ||
| - Proxy Pattern | ||
|
|
||
| ### Behavioral Patterns (11) | ||
| - Observer Pattern | ||
| - Template Method Pattern | ||
| - Command Pattern | ||
| - State Pattern | ||
| - Chain of Responsibility Pattern | ||
| - Interpreter Pattern | ||
| - Mediator Pattern | ||
| - Visitor Pattern | ||
| - Memento Pattern | ||
| - Iterator Pattern | ||
| - Strategy Pattern |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| # 设计模式 UML 类图 | ||
|
|
||
| 本文件夹包含了本仓库中实现的所有设计模式的 UML 类图。 | ||
|
|
||
| ## 目录结构 | ||
|
|
||
| - `creational/` - 创建型模式的 UML 类图 | ||
| - `structural/` - 结构型模式的 UML 类图 | ||
| - `behavioral/` - 行为型模式的 UML 类图 | ||
|
|
||
| ## 格式 | ||
|
|
||
| 所有类图均采用 PlantUML 格式(.puml 文件),可使用各种工具渲染为图像。 | ||
|
|
||
| ## 使用方法 | ||
|
|
||
| 渲染这些类图的方法: | ||
| 1. **在线工具**:使用在线渲染器 http://www.plantuml.com/plantuml/uml/ | ||
| 2. **本地安装**:本地安装 PlantUML | ||
| 3. **VS Code**:安装 PlantUML 扩展,支持内联预览和渲染 | ||
| 4. **IDE 插件**:使用适用于 IntelliJ IDEA、Eclipse 和其他 IDE 的 PlantUML 插件 | ||
|
|
||
| 打开 .puml 文件并将其渲染为 PNG/SVG 图像 | ||
|
|
||
| ## 包含的模式 | ||
|
|
||
| ### 创建型模式 (6种) | ||
| - 简单工厂模式 (Simple Factory Pattern) | ||
| - 抽象工厂模式 (Abstract Factory Pattern) | ||
| - 工厂方法模式 (Factory Method Pattern) | ||
| - 建造者模式 (Builder Pattern) | ||
| - 原型模式 (Prototype Pattern) | ||
| - 单例模式 (Singleton Pattern) | ||
|
|
||
| ### 结构型模式 (7种) | ||
| - 适配器模式 (Adapter Pattern) | ||
| - 桥接模式 (Bridge Pattern) | ||
| - 组合模式 (Composite Pattern) | ||
| - 装饰器模式 (Decorator Pattern) | ||
| - 外观模式 (Facade Pattern) | ||
| - 享元模式 (Flyweight Pattern) | ||
| - 代理模式 (Proxy Pattern) | ||
|
|
||
| ### 行为型模式 (11种) | ||
| - 观察者模式 (Observer Pattern) | ||
| - 模板方法模式 (Template Method Pattern) | ||
| - 命令模式 (Command Pattern) | ||
| - 状态模式 (State Pattern) | ||
| - 职责链模式 (Chain of Responsibility Pattern) | ||
| - 解释器模式 (Interpreter Pattern) | ||
| - 中介者模式 (Mediator Pattern) | ||
| - 访问者模式 (Visitor Pattern) | ||
| - 备忘录模式 (Memento Pattern) | ||
| - 迭代器模式 (Iterator Pattern) | ||
| - 策略模式 (Strategy Pattern) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| @startuml Chain of Responsibility Pattern | ||
| !theme plain | ||
|
|
||
| title Chain of Responsibility Pattern | ||
|
|
||
| abstract class Manager { | ||
| #ManagerName: string | ||
| #Superior: Manager | ||
| +Manager(managerName: string) | ||
| +SetSuperior(superior: Manager): void | ||
| +{abstract} RequestApplications(request: Request): void | ||
| } | ||
|
|
||
| class CommonManager { | ||
| +CommonManager(managerName: string) | ||
| +RequestApplications(request: Request): void | ||
| } | ||
|
|
||
| class Majordomo { | ||
| +Majordomo(managerName: string) | ||
| +RequestApplications(request: Request): void | ||
| } | ||
|
|
||
| class GeneralManager { | ||
| +GeneralManager(managerName: string) | ||
| +RequestApplications(request: Request): void | ||
| } | ||
|
|
||
| class Request { | ||
| +RequestType: string | ||
| +RequestContent: string | ||
| +RequestNum: int | ||
| } | ||
|
|
||
| class Client { | ||
| +Main(): void | ||
| } | ||
|
|
||
| Manager <|-- CommonManager | ||
| Manager <|-- Majordomo | ||
| Manager <|-- GeneralManager | ||
|
|
||
| Manager -> Manager : successor | ||
| Manager -> Request : handles | ||
|
|
||
| Client -> Manager : uses | ||
| Client -> Request : creates | ||
|
|
||
| note right of Manager | ||
| Handler defines interface | ||
| for handling requests and | ||
| implements successor link | ||
| end note | ||
|
|
||
| note right of CommonManager | ||
| CommonManager handles requests | ||
| for leave <= 2 days, otherwise | ||
| passes to successor | ||
| end note | ||
|
|
||
| note right of Majordomo | ||
| Majordomo handles requests | ||
| for leave <= 5 days, otherwise | ||
| passes to successor | ||
| end note | ||
|
|
||
| note right of GeneralManager | ||
| GeneralManager handles all | ||
| leave requests and salary | ||
| increase <= 500 | ||
| end note | ||
|
|
||
| note top of Manager | ||
| Chain of Responsibility passes | ||
| request along chain of handlers | ||
| until one handles it | ||
| end note | ||
|
|
||
| @enduml |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| @startuml Command Pattern | ||
| !theme plain | ||
|
|
||
| title Command Pattern | ||
|
|
||
| abstract class Command { | ||
| #Receiver: Receiver | ||
| +Command(receiver: Receiver) | ||
| +{abstract} Execute(): void | ||
| } | ||
|
|
||
| class ConcreteCommand { | ||
| +ConcreteCommand(receiver: Receiver) | ||
| +Execute(): void | ||
| } | ||
|
|
||
| class Receiver { | ||
| +Action(): void | ||
| } | ||
|
|
||
| class Invoker { | ||
| -command: Command | ||
| +SetCommand(command: Command): void | ||
| +ExecuteCommand(): void | ||
| } | ||
|
|
||
| abstract class OrderCommand { | ||
| #Receiver: Barbecuer | ||
| +OrderCommand(receiver: Barbecuer) | ||
| +{abstract} ExecuteCommand(): void | ||
| } | ||
|
|
||
| class BakeMuttonCommand { | ||
| +BakeMuttonCommand(receiver: Barbecuer) | ||
| +ExecuteCommand(): void | ||
| +ToString(): string | ||
| } | ||
|
|
||
| class BakeChickenWingCommand { | ||
| +BakeChickenWingCommand(receiver: Barbecuer) | ||
| +ExecuteCommand(): void | ||
| +ToString(): string | ||
| } | ||
|
|
||
| class Barbecuer { | ||
| +BakeMutton(): void | ||
| +BakeChickenWing(): void | ||
| } | ||
|
|
||
| class Waiter { | ||
| -orders: ICollection<OrderCommand> | ||
| +SetOrder(order: OrderCommand): void | ||
| +CancelOrder(order: OrderCommand): void | ||
| +Notify(): void | ||
| } | ||
|
|
||
| class Client { | ||
| +Main(): void | ||
| } | ||
|
|
||
| Command <|-- ConcreteCommand | ||
| Command -> Receiver | ||
| Invoker -> Command | ||
|
|
||
| OrderCommand <|-- BakeMuttonCommand | ||
| OrderCommand <|-- BakeChickenWingCommand | ||
| OrderCommand -> Barbecuer | ||
| Waiter *-- OrderCommand | ||
|
|
||
| Client -> Invoker : uses | ||
| Client -> Waiter : uses | ||
|
|
||
| note right of Command | ||
| Command declares interface | ||
| for executing an operation | ||
| end note | ||
|
|
||
| note right of ConcreteCommand | ||
| ConcreteCommand defines binding | ||
| between Receiver object and action. | ||
| Implements Execute by invoking | ||
| corresponding operations on Receiver | ||
| end note | ||
|
|
||
| note right of Invoker | ||
| Invoker asks command to | ||
| carry out the request | ||
| end note | ||
|
|
||
| note right of Waiter | ||
| Waiter manages multiple orders | ||
| and can execute them in batch | ||
| end note | ||
|
|
||
| @enduml |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| @startuml Interpreter Pattern | ||
| !theme plain | ||
|
|
||
| title Interpreter Pattern | ||
|
|
||
| class Context { | ||
| +Input: string | ||
| +Output: string | ||
| } | ||
|
|
||
| abstract class AbstractExpression { | ||
| +{abstract} Interpret(context: Context): void | ||
| } | ||
|
|
||
| class TerminalExpression { | ||
| +Interpret(context: Context): void | ||
| } | ||
|
|
||
| class NoneTerminalExpression { | ||
| +Interpret(context: Context): void | ||
| } | ||
|
|
||
| class PlayContext { | ||
| +PlayText: string | ||
| } | ||
|
|
||
| abstract class MusicalExpression { | ||
| +Interpret(context: PlayContext): void | ||
| +{abstract} Execute(key: string, value: double): void | ||
| } | ||
|
|
||
| class MusicalNote { | ||
| +Execute(key: string, value: double): void | ||
| } | ||
|
|
||
| class MusicalScale { | ||
| +Execute(key: string, value: double): void | ||
| } | ||
|
|
||
| class MusicalSpeed { | ||
| +Execute(key: string, value: double): void | ||
| } | ||
|
|
||
| class Client { | ||
| +Main(): void | ||
| } | ||
|
|
||
| AbstractExpression <|-- TerminalExpression | ||
| AbstractExpression <|-- NoneTerminalExpression | ||
| AbstractExpression -> Context : interprets | ||
|
|
||
| MusicalExpression <|-- MusicalNote | ||
| MusicalExpression <|-- MusicalScale | ||
| MusicalExpression <|-- MusicalSpeed | ||
| MusicalExpression -> PlayContext : interprets | ||
|
|
||
| Client -> AbstractExpression : uses | ||
| Client -> MusicalExpression : uses | ||
| Client -> Context : uses | ||
| Client -> PlayContext : uses | ||
|
|
||
| note right of AbstractExpression | ||
| AbstractExpression declares | ||
| abstract Interpret operation | ||
| that is common to all nodes | ||
| in abstract syntax tree | ||
| end note | ||
|
|
||
| note right of TerminalExpression | ||
| TerminalExpression implements | ||
| Interpret operation for | ||
| terminal symbols in grammar | ||
| end note | ||
|
|
||
| note right of MusicalExpression | ||
| Concrete example: interprets | ||
| musical notation including | ||
| notes, scales, and speeds | ||
| end note | ||
|
|
||
| note top of AbstractExpression | ||
| Interpreter pattern defines | ||
| representation for grammar | ||
| and interpreter to interpret | ||
| sentences in the language | ||
| end note | ||
|
|
||
| @enduml |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.