33
ASP.NET MVC之實戰架構探討 MVC真的不是只有簡單的ModelViewController三層喔! Bibby Chung http://bibby.be

ASP.NET MVC之實戰架構探討 -twMVC#5

  • Upload
    twmvc

  • View
    856

  • Download
    7

Embed Size (px)

DESCRIPTION

內容大綱為: Architecture Overview Design Principles and Patterns Design of the System Final Thoughts Examples of Discussion http://mvc.tw

Citation preview

Page 1: ASP.NET MVC之實戰架構探討 -twMVC#5

ASP.NET MVC之實戰架構探討

MVC真的不是只有簡單的Model、View、Controller三層喔!

Bibby Chung http://bibby.be

Page 2: ASP.NET MVC之實戰架構探討 -twMVC#5

三屆微軟最有價值專家經歷(ASP.NET)

藍色小舖 高級專家

twMVC 聯合創辦人之一

目前於金融業及手機 APP 領域發展

講者簡介

Bibby Chung http://bibby.be

2

Page 3: ASP.NET MVC之實戰架構探討 -twMVC#5

本投影片所包含的商標與文字皆屬原著作者所有。

本投影片使用的圖片皆從網路搜尋。

本著作係採用 Creative Commons 姓名標示-非商業性-相

同方式分享 3.0 台灣 (中華民國) 授權條款授權。

版權宣告

3

Page 4: ASP.NET MVC之實戰架構探討 -twMVC#5

Architecture Overview

Design Principles and Patterns

Design of the System

ASP.NET MVC with N-Layer Architecture

Examples of Discussion

Final Thoughts

Agenda

4

Page 5: ASP.NET MVC之實戰架構探討 -twMVC#5

什麼是軟體架構設計

軟體架構重要

好處

壞處

5

Architecture Overview

Page 6: ASP.NET MVC之實戰架構探討 -twMVC#5

6

Architecture Overview

Page 7: ASP.NET MVC之實戰架構探討 -twMVC#5

物件導向設計(Object-Oriented Design)

開放封閉原則(OCP)

避免重複原则(DRY)

單一責任原則(SRP)

7

Design Principles and Patterns

Page 8: ASP.NET MVC之實戰架構探討 -twMVC#5

物件導向設計(Object-Oriented Design)

裡氏代換原則(LSP)

相依性反向原則(DIP)

介面分隔原則(ISP)

8

Design Principles and Patterns

Page 9: ASP.NET MVC之實戰架構探討 -twMVC#5

關注點分離(Separation of Concerns)

什麼是關注點

模組化

隱藏細節資訊

9

Design Principles and Patterns

Page 10: ASP.NET MVC之實戰架構探討 -twMVC#5

命名方式(Naming Conventions)

參考微軟的官方命名規則

自定命名方式

可讀性(Code Readability)

註解

區塊小

10

Design Principles and Patterns

Page 11: ASP.NET MVC之實戰架構探討 -twMVC#5

設計之前

系統最終的目的是?

功能需求還是非功能需求?

專案品質要求?

衝突與取捨

11

Design of the System

Page 12: ASP.NET MVC之實戰架構探討 -twMVC#5

設計之前

有多少時間可以使用,專案開始時間專案結束時間?

有多少的資源可以使用?

你的系統要做多大?

可擴充的系統需的嗎?

12

Design of the System

Page 13: ASP.NET MVC之實戰架構探討 -twMVC#5

第一步

選擇你的分層策略

決定哪些層你需要的

未來專案如何佈署

判斷是否您只需要一層

13

Design of the System

Page 14: ASP.NET MVC之實戰架構探討 -twMVC#5

第一步

哪些物件規則是需要跨層的

不同層如何互動

不同層如何傳遞資料

14

Design of the System

Page 15: ASP.NET MVC之實戰架構探討 -twMVC#5

N-Layer

Presentation Layer

Business Layer

Data Layer

15

Design of the System

Page 16: ASP.NET MVC之實戰架構探討 -twMVC#5

Layers

Presentation Layer

Services Layer

Business Layer

Data Layer

16

Design of the System

Page 17: ASP.NET MVC之實戰架構探討 -twMVC#5

17

Design of the System

Page 18: ASP.NET MVC之實戰架構探討 -twMVC#5

18

Design of the System

Page 19: ASP.NET MVC之實戰架構探討 -twMVC#5

Presentation Layer

控制項

多工

驗證

19

Design of the System

Page 20: ASP.NET MVC之實戰架構探討 -twMVC#5

Business Layer

Service Layer

表象模式(Façade Pattern)

20

Design of the System

Page 21: ASP.NET MVC之實戰架構探討 -twMVC#5

Data Layer

連線管理

資料傳遞

O/RM or ADO.NET

安全性

21

Design of the System

Page 22: ASP.NET MVC之實戰架構探討 -twMVC#5

Cross-Cutting

驗證身分 & 授權

快取機制、狀態管理

驗證

22

Design of the System

Page 23: ASP.NET MVC之實戰架構探討 -twMVC#5

Cross-Cutting

設定管理

例外處理

日誌管理

23

Design of the System

Page 24: ASP.NET MVC之實戰架構探討 -twMVC#5

24

ASP.NET MVC with N-Layer Architecture

Page 25: ASP.NET MVC之實戰架構探討 -twMVC#5

建立五個專案

一個 ASP.NET MVC 專案

四個 Class Library 專案

Models 跟 Common 所有專案加入參考

Web 加入 Services

Services 加入 Repositories

25

Examples of Discussion

Page 26: ASP.NET MVC之實戰架構探討 -twMVC#5

26

Examples of Discussion

Page 27: ASP.NET MVC之實戰架構探討 -twMVC#5

27

Examples of Discussion

Page 28: ASP.NET MVC之實戰架構探討 -twMVC#5

這例子需要加強部分

沒有遵守DIP(Dependency Inversion Principle)

實作抽象

IOC Library運用

如何測試

實作抽象加入測試專案

28

Examples of Discussion

Page 29: ASP.NET MVC之實戰架構探討 -twMVC#5

29

Examples of Discussion

Page 30: ASP.NET MVC之實戰架構探討 -twMVC#5

30

Examples of Discussion

Page 32: ASP.NET MVC之實戰架構探討 -twMVC#5

Blog http://bibby.be

Facebook http://fb.me/bibbynet

Plurk http://www.plurk.com/bibbynet

32

聯絡我

Bibby Chung http://bibby.be

Page 33: ASP.NET MVC之實戰架構探討 -twMVC#5

http://mvc.tw

台灣 ASP.NET MVC 專業推廣團隊