Skip to Content
JAVASCRIPT網頁應用程式設計
book

JAVASCRIPT網頁應用程式設計

by Alex MacCaw
January 2013
Intermediate to advanced
332 pages
5h 23m
Chinese
GoTop Information, Inc.
Content preview from JAVASCRIPT網頁應用程式設計
MVC 和類別(Classes
|
3
來開發 JavaScript 程式,就像用其他程式語言(像 Python Ruby)開發系統一樣。大
家都知道在開發伺服器端(server-side)應用程式時,一定要妥善規劃好系統架構,那
麼為什麼開發用戶端(client-side)應用程式時,就不該比照辦理呢?
本書所採用的,是一種名為 MVC 的設計模式,這可說是一種許多專家學者反覆驗證、
測試過的優良系統架構,套用這樣的架構,日後就能更有效率的維護和擴充系統功能。
而且 MVC 特別適合套用在 JavaScript 應用程式上。
何謂 MVC
MVC 是一種設計模式,它將應用程式拆解成三部分:模型(Model)、檢視器(View),
以及控制器(Controller)。它讓程式處理事件的流程,變成像這樣:
1. 使用者操作應用程式。
2. 使用者的操作會觸發控制器的事件處理器。
3. 控制器會取出儲存在模型裡的資料,然後轉交給檢視器。
4. 使用者可以透過檢視器看到資料。
接下來用一個實際的範例來說明,圖 1-1 是在說明如何利用 Holla 來傳送新的聊天訊息。
1-1 利用 Holla 傳送新的聊天訊息
1. 使用者送出一則新的聊天訊息。
2. 使用者的動作,觸發了控制器的事件處理器。
3. 控制器建立一組新模型(名稱為 Chat)。
4. 控制器接著更新檢視器的內容。
5. 使用者會在聊天記錄中,看到他剛才所輸入的聊天訊息。
3
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

初めてのJavaScript 第3版 ―ES2015以降の最新ウェブ開発

初めてのJavaScript 第3版 ―ES2015以降の最新ウェブ開発

Ethan Brown, 武舎 広幸, 武舎 るみ
PHP编程:第4版

PHP编程:第4版

Kevin Tatroe, Peter MacIntyre
Strange Code

Strange Code

Ronald T. Kneusel
Perfecting Your Thinking Skills

Perfecting Your Thinking Skills

MIT Sloan Management Review

Publisher Resources

ISBN: 9789862766811