Design Pattern
  • Introduction
  • Chapter1: MVVM
  • Chapter2: 觀察者模式 (Observer Pattern)
  • Chapter3: 策略模式 (Strategy Pattern)
  • Chapter4: 單例/獨體模式 (Singleton)
  • Chapter5: 裝飾者模式 (Decorater Pattern)
  • Chapter6: 命令模式 (Command Pattern)
  • Chapter7: MVC
Powered by GitBook
On this page
  • This section contain the following items:
  • 1.MVC (Model-View-ConTroller)

Was this helpful?

Chapter7: MVC

PreviousChapter6: 命令模式 (Command Pattern)

Last updated 5 years ago

Was this helpful?

This section contain the following items:

  • 1.MVC

1.MVC (Model-View-ConTroller)

  • 1.Model, View, Controller:

    • Model (模型)

      • 用來表示與實作出應用程式內的各種資料物件,並且包含了商業處理邏輯。

    • View (檢視)

      • 表示應用程式中的使用者介面(UI)所要顯示的各個元件。

    • Controller (控制器)

    • 使用者接觸的對象用來處理使用者的互動與處理資料模型物件, 負責改變Model的狀態或是改變View的顯示

  • 2.MVC的優點

    • 讓視圖, 運算邏輯及資料解耦:

      • 一旦程式的邏輯發生變化便只要修改部分模組或添加新的模組即可

      • 一旦程式的視圖需要修改, 可以直接抽換掉

    • 增加重複使用性, 並使系統更方便維護

  • 3.MVC結合了, , 合成模式的優點

    • MVC元件彼此間的互動方式

    • : 例如View等同於被觀察者, Model, Controller等同於觀察者

    • : View背後的Controller隨時可以抽換

    • 合成模式: View可以由多個UI Component組成

觀察者模式
策略模式
觀察者模式
策略模式