Skip to Content
JavaScript 設計模式
book

JavaScript 設計模式

by Stoyan Stefanov
March 2012
Intermediate to advanced
244 pages
4h 42m
Chinese
GoTop Information, Inc.
Content preview from JavaScript 設計模式
2
   
第一章
辨認出模式是很重要的,因為:

模式幫助我們使用前人已經驗證過的優良實踐方式,編寫出更好的程式碼,而不必
重新發明輪子。

模式提供了一定程度的抽象化概念 畢竟大腦一次就只能記住那麼幾件事,所以當
你在思考一個很複雜的問題時,模式可以幫助你不必被太過瑣碎的細節擾亂,因為
模式本身已經解釋了這些細節。

模式增強了開發者和團隊之間的溝通。開發者可能彼此遠在不同地方,難以面對面
溝通。將一些程式設計的技巧或者實踐方式取一個名字,可以更容易確定彼此是在
談論同一件事情。例如,與其說「這東西就是你用括號把函式包起來,然後在後面
加上另一組括號,好讓你在定義函式的地方就立刻執行」,不如說「立即函式」
immediate function)來得更容易表達也更容易理解。
本書討論以下幾種模式:

設計模式(Design patterns

編碼模式(Coding patterns

反模式(Antipatterns
設計模式一開始是在「四人幫」(Gang of Four)的經典書籍:物件導向設計模式:可再
利用物件導向軟體之要素1994年出版)之中定義。本書的範例中包含了 singleton(單
體模式)、factory(工廠模式)、decorator(裝飾者模式)、observer(觀察者模式)和
其他模式。雖然設計模式的研究幾乎都使用強型別的語言,例如 C++ Java ,實在沒什
麼道理使用像 JavaScript 這麼一個鬆散型別的動態語言來實踐設計模式。有時候這些
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 之美

JavaScript 之美

Anton Kovalyov
重構 JavaScript

重構 JavaScript

Evan Burchard

Publisher Resources

ISBN: 9789862764190