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網頁應用程式設計
第六章
相依性管理(Dependency
Management
由於 JavaScript 沒有內建任何相依性管理和模組管理的機制,所以總會讓人誤以為這是
套不成熟的程式語言。說也奇怪,大部分人在學習 JavaScript 時,就是不會像學習其他
程式語言一樣,把學習重心放在命名空間以及模組等觀念上。即使是像 jQuery 這樣知名
JavaScript 函式庫,也不會強制我們一定得套用或遵循任何特定程式架構。程式設計
師往往得靠自己去規劃、管理程式架構。正因如此,在我們周遭,隨處可見一些毫無章
法、寫滿了無數縮排程式碼和匿名函式,而且混亂得像義大利麵團的 JavaScript 程式。
相信像以下這樣的程式撰寫風格,各位一定都不陌生:
function() {
function() {
function() {
function() {
}
}
}
}
沒有妥善運用命名空間和模組觀念倒還事小,但 JavaScript 沒有內建相依性管理機制的
這個問題,已經逐漸成為開發大型應用程式時,無法等閒視之的嚴重問題。過去有很長
一段時間,程式設計師們都以為只要不斷在網頁上面添加
script
標籤就夠,但那只是
因為網頁裡需要用到的 JavaScript 程式檔案還不夠多。一旦開始開發規模龐雜、需要動
用非常多相依檔案的應用程式時,就一定得仰賴相依性管理工具的輔助。透過手動設定
script 標籤的方式來管理所有的相依檔案,會讓程式變得很難維護。如果堅持這麼做,
最後一定會讓程式碼變得一團混亂:
<script src="jquery.js" ...
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