Skip to content

Complete C# implementation of 23 GoF design patterns with UML models, OOP foundations, and interactive console examples based on e-commerce scenarios.

Notifications You must be signed in to change notification settings

kenming/thinking-in-design-patterns-csharp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

《把軟體作軟的設計模式思維》範例資源

Thinking in Design Patterns with C# and UML

🎯 專案簡介

本儲存庫是《[書名待定] - 把軟體作軟的設計模式思維》一書的完整範例程式碼與 UML 模型檔,包含以下內容:

資源類型 說明 對應書籍章節
🏗️ 設計模式範例專案 23個設計模式的 C# 完整實作範例,基於電子商務場景 Ch03-Ch25
📚 物件導向基礎專案 物件導向程式設計基礎概念的 C# 實作範例 Ch01
📐 UML設計模型檔案 書中所有 UML 設計圖的 Model 檔案(使用 Sparx EA 繪製) 全書

💡 範例程式碼特色

  • 完整註解:每個範例都包含詳細的中文註解,說明設計意圖與實作細節
  • 實戰導向:基於真實的電子商務領域業務場景
  • 統一架構:一致的專案結構與編碼規範
  • 即時執行:Console 界面,互動式選單用以選擇任一模式並可反覆執行。

🚀 快速開始

環境需求

  • .NET 8.0+ SDK
  • Visual Studio 2022 或 Visual Studio Code
  • Enterprise Architect(可選,用於檢視 UML 模型檔案)

專案結構

thinking-in-design-patterns-csharp/
├── 📁 docs/                              # 說明文件資料夾
│   ├── 📄 README-DesignPatterns.md       # 設計模式說明文件
│   ├── 📄 README-ObjectFoundamental.md   # 物件導向基礎說明文件
│   └── 📄 README-UML-Guide.md            # UML 建模指南文件
│   │
├── 📁 model/                             # UML 模型資料夾
│   └── 📄 thinking-in-design-patterns.qea # 設計模式 UML 模型檔案
│   │
└── 📁 src/                               # 範例程式碼目錄
    ├── 📁 DesignPatternsSolution/        # 設計模式範例專案
    │   ├── 📁 .vscode/                   # VS Code 設定檔
    │   └── 📁 DesignPatterns/            # 設計模式範例
    │       ├── 📁 Behavioral/            # 行為型模式
    │       ├── 📁 Creational/            # 創建型模式
    │       ├── 📁 Structural/            # 結構型模式
    │       └── 📁 Utils/                 # 工具類別
    │       └── 📄 Program.cs             # 主程式入口點
    │
    └── 📁 OOFundamentalSolution/         # 物件導向基礎範例專案
        └── 📁 OOFundamental/             # 物件導向基礎實作
            ├── 📁 1.Association/         # 關聯關係
            ├── 📁 2.Whole-parts/         # 整體-局部關係
            └── 📁 3.Generalization-Specialization/ # 一般化-特殊化關係
            └── 📄 Program.cs             # 主程式入口點

🛠️ 快速執行範例

📚 物件導向基礎範例

命令列執行:

cd src/OOFundamentalSolution
dotnet run

或 Visual Studio 執行:

  1. 開啟 Visual Studio 2022
  2. 選擇 File > Open > Project/Solution,開啟 .sln 檔案
  3. 按下 F5 執行專案

👉 查看物件導向基礎範例執行說明

🏗️ 設計模式完整範例

命令列執行:

cd src/DesignPatternsSolution
dotnet run

或 Visual Studio 執行:

  1. 開啟 Visual Studio 2022
  2. 選擇 File > Open > Project/Solution,開啟 .sln 檔案
  3. 按下 F5 執行專案

👉 查看設計模式完整範例執行說明

📐 UML 模型檔案

  1. 下載並安裝 Enterprise Architect Viewer
  2. 開啟 model/thinking-in-design-patterns.qea 檔案
  3. 瀏覽專案瀏覽器中的章節結構

👉 查看 UML 模型所有範例設計圖

🤝 貢獻指南

歡迎提交 Issue 或 Pull Request 來改善範例程式碼!

  1. Fork 此專案
  2. 建立功能分支 (git checkout -b feature/amazing-feature)
  3. 提交變更 (git commit -m 'Add some amazing-feature')
  4. 推送到分支 (git push origin feature/amazing-feature)
  5. 開啟 Pull Request

貢獻規範

  • 請遵循現有的程式碼風格和註解規範
  • 確保所有範例程式碼都能正常編譯和執行
  • 新增功能時請同時更新對應的文件說明

📄 授權條款

a. 範例程式碼授權

本專案的範例程式碼採用 MIT 授權,允許使用者:

  • ✅ 自由使用、複製、修改、合併、出版發行、再授權和販售軟體
  • ✅ 將軟體用於任何目的,包括商業用途
  • ✅ 只需在軟體和軟體的所有副本中包含原始授權聲明

b. UML 模型檔案授權

UML 設計模型檔案採用 Creative Commons Attribution 4.0 International 授權:

  • ✅ 允許分享和適應這些設計檔案
  • ✅ 需註明出處來源
  • ❌ 不得用於商業用途

👨‍💻 作者聯繫與社群

📞 聯絡方式

Kenming Wang

📱 社群與討論

  • Facebook 社團 : 軟體設計鮮思維社團
  • GitHub Issues : 用於技術問題和錯誤回報
  • GitHub Discussions : 用於本書關於設計模式與物件導向相關議題討論和問答

QR Code

聯絡QR Code

掃描 QR Code 獲取作者聯絡方式、社群連結與專案儲庫位址

About

Complete C# implementation of 23 GoF design patterns with UML models, OOP foundations, and interactive console examples based on e-commerce scenarios.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages