From 289192f4c0c6809238bbd9461f829ef1eb75c945 Mon Sep 17 00:00:00 2001
From: PhucVR <59957741+nguyenphuc22@users.noreply.github.com>
Date: Mon, 22 Jan 2024 22:08:45 +0700
Subject: [PATCH] Update Mediator.md
---
.idea/Design-Patterns.iml | 9 +++++++++
.idea/modules.xml | 8 ++++++++
.idea/workspace.xml | 20 +++++++-------------
Writerside/topics/Mediator.md | 12 ++++++++++--
4 files changed, 34 insertions(+), 15 deletions(-)
create mode 100644 .idea/Design-Patterns.iml
create mode 100644 .idea/modules.xml
diff --git a/.idea/Design-Patterns.iml b/.idea/Design-Patterns.iml
new file mode 100644
index 0000000..d6ebd48
--- /dev/null
+++ b/.idea/Design-Patterns.iml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..872399f
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 3dcb891..39ede29 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,7 +4,9 @@
-
+
+
+
@@ -52,6 +54,9 @@
+
@@ -62,20 +67,9 @@
"RunOnceActivity.OpenProjectViewOnStart": "true",
"RunOnceActivity.ShowReadmeOnStart": "true",
"git-widget-placeholder": "main",
+ "kotlin-language-version-configured": "true",
"last_opened_file_path": "/Users/phucnguyen/Documents/GitHub/Design-Patterns/Writerside/topics",
"settings.editor.selected.configurable": "fileTemplates"
- },
- "keyToStringList": {
- "stardust.markdown.MarkdownSplitEditorSuppressor:keyList": [
- "/Users/phucnguyen/Documents/GitHub/Design-Patterns/Writerside/topics/Builder.md",
- "/Users/phucnguyen/Documents/GitHub/Design-Patterns/Writerside/topics/Chain-Of-Responsibility.md",
- "/Users/phucnguyen/Documents/GitHub/Design-Patterns/Writerside/topics/Command.md",
- "/Users/phucnguyen/Documents/GitHub/Design-Patterns/Writerside/topics/Creational-Patterns.md",
- "/Users/phucnguyen/Documents/GitHub/Design-Patterns/Writerside/topics/Iterator.md",
- "/Users/phucnguyen/Documents/GitHub/Design-Patterns/Writerside/topics/Mediator.md",
- "/Users/phucnguyen/Documents/GitHub/Design-Patterns/Writerside/topics/Proxy.md",
- "/Users/phucnguyen/Documents/GitHub/Design-Patterns/Writerside/topics/Singleton.md"
- ]
}
}]]>
diff --git a/Writerside/topics/Mediator.md b/Writerside/topics/Mediator.md
index ca8783e..fab5529 100644
--- a/Writerside/topics/Mediator.md
+++ b/Writerside/topics/Mediator.md
@@ -308,6 +308,14 @@ classDiagram
Trong đoạn code trên, `ChatServer` đóng vai trò là mediator, quản lý việc gửi tin nhắn giữa các `User`. Các `User` không giao tiếp trực tiếp với nhau mà thông qua `ChatServer`.
-## Kết luận
+## Khi nào nên sử dụng Mediator Pattern
-Mediator Pattern hữu ích để giảm sự phụ thuộc trực tiếp giữa các lớp, dễ dàng mở rộng và thay đổi chương trình. Tuy nhiên cũng cần tránh lạm dụng mediator dẫn tới phức tạp hóa code.
\ No newline at end of file
+- **Khi bạn muốn giảm sự phụ thuộc lẫn nhau giữa các lớp hoặc các module**: Mediator Pattern giúp các lớp hoặc module không trực tiếp giao tiếp với nhau, mà thông qua một "trung gian", giảm sự phụ thuộc và tăng khả năng tái sử dụng.
+
+- **Khi hệ thống của bạn có quá nhiều giao tiếp trực tiếp giữa các đối tượng và bạn muốn quản lý hoặc giảm thiểu sự phức tạp này**: Mediator Pattern tập trung giao tiếp giữa các đối tượng vào một điểm duy nhất, làm cho quản lý và hiểu hệ thống trở nên dễ dàng hơn.
+
+- **Trong các ứng dụng muốn cung cấp khả năng mở rộng cao**: Khi sử dụng Mediator, việc thêm hoặc sửa đổi các thành phần của hệ thống trở nên dễ dàng hơn mà không làm ảnh hưởng đến các thành phần khác.
+
+- **Khi cần đảm bảo sự cô lập giữa các thành phần của hệ thống**: Mediator giúp các thành phần giữ được sự độc lập, giảm thiểu rủi ro khi một phần của hệ thống thay đổi hoặc gặp sự cố.
+
+- **Trong việc xây dựng các ứng dụng GUI**: Mediator thường được sử dụng trong các ứng dụng giao diện người dùng để quản lý sự tương tác giữa các thành phần GUI, giúp giảm sự phức tạp trong quản lý sự kiện và trạng thái.