易讀代碼的藝術(shù)

出版時(shí)間:2012-6  出版社:東南大學(xué)出版社  作者:Dustin Boswell,Trevor Foucher  頁數(shù):190  字?jǐn)?shù):250000  
Tag標(biāo)簽:無  

內(nèi)容概要

作為程序員,我們經(jīng)??吹揭恍┏錆MBug、讓我們頭痛不已的丑陋代碼。在過去五年中,《易讀代碼的藝術(shù)(影印版)》的作者博斯韋爾(Dustin
Boswell)和富徹(Trevor
Foucher)分析了許多這樣的“糟糕代碼”(這些代碼有很多是出自于他們自己之手),他們試圖厘清為什么這些代碼如此糟糕以及如何改進(jìn)這些代碼。他們得出的結(jié)論是:你必須寫出讓他人(這里也包括你自己)花費(fèi)最少時(shí)間能夠理解的代碼。

作者簡介

  Dustin Boswell,畢業(yè)于加州理工學(xué)院,在谷歌公司從事過五年的Web信息采集基礎(chǔ)設(shè)施和廣告營銷計(jì)劃的研究工作。他先后構(gòu)建過多個Web站點(diǎn),目前的主要研究興趣在于大數(shù)據(jù)的處理和機(jī)器學(xué)習(xí)領(lǐng)域的相關(guān)技術(shù)?! revor Foucher,過去十年中先后在微軟公司擔(dān)任Windows及安全相關(guān)產(chǎn)品的工程師、經(jīng)理和技術(shù)領(lǐng)導(dǎo)者的職務(wù),現(xiàn)任職于谷歌公司,主要從事谷歌廣告營銷計(jì)劃和搜索基礎(chǔ)設(shè)施的研究工作。

書籍目錄

PREFACE
CODE SHOULD BE EASY TO UNDERSTAND
What Makes Code "Better"?
The Fundamental Theorem of Readability
Is Smaller Always Better?
Does Time-TilI-UndetandinR Conflict with Other Goals?
The Hard Part
Part One SURFACE-LEVEL IMPROVEMENTS
PACKING INFORMATION INTO NAMES
Choose Specific Words
Auoid Generic Names Like Imp and retual
Prefer Concrete Names ouer Abstract Names
Attachin9 Extra Information to a Name
How Lon.g Should a Name Be?
Use Name Formatting to Conuey Meaning
Summary
NAMES THAT CAN'T BE MISCONSTRUED
Example: FilterO
Example: Clip(text, length)
Prefer rain and max for (Inclusiue) Limits
Prefer fit and last for Inelusiue RanRes
Prefer herin and end for.lnclusiue/Exclusiue RanRes
NaminR Boolea
MatchinR Expectatio of Use
Example: EualuatinR Multiple Name Candidates
Summary
AESTHETICS
Why Do Aesthetics Matter?
BearranRe Line Breaks to Be Coistent and Compact
Use Methods to Clean Up IrreRularity
Use Column AliRnment When Helpful
Pick a MeaninRful Order, and Use It Coistently
OrRanize Declaratio into Blocks
Break Code into "Parafgraphs"
Peonal Style ueus Coistency
Summary
KNOWING WHAT TO COMMENT
What NOT to Comment
Becordin9 Your Thouyhts
Put Youelf in the Reader's Shoes
Final Thoughts--Getting Over Writer's Block
Summary
MAKING COMMENTS PRECISE AND COMPACT
Keep Comments Compact
Avoid Ambiguous Pronou
Polish Sloppy Sentences
Describe Function Behavior Precisely
Use Input/Output Examples That Illustrate Corner Cases
State the Intent of Your Code
"Named Function Parameter" Comments
Use Information-Dee Words
Summary
Part Two SIMPLIFYING LOOPS AND LOGIC
MAKING CONTROL FLOW EASY TO READ
The Order of Arguments in Conditionals
The Order of if/else Blocks
The ?: Conditional Expression (a.k.a. "Ternary Operator")
Avoid dogwhile Loops
Returning Early from a Function
The Infamous goto
Minimize Nesting
Can You Follow the Flow of Execution?
Summary
BREAKING DOWN GIANT EXPRESSIONS
Explainin9 Variables
Summary Variables
Using De Morgan's Laws
Abusing Short-Circuit Logic
Example: Wrestling with Complicated Logic
Breaking Down Giant Statements
Another Creative Way to Simplify Expressio
Summary
VARIABLES AND READABILITY
Eliminatinfg Variables
Shrink the Scope of Your Variables
Prefer Write-Once Variables
A Final Example
Summary
Part Three REORGANIZING YOUR CODE
EXTRACTING UNRELATED SUBPROBLEMS
Introductory Example: findClosestLoeationO
Pure Utility Code
Other General-Purpose Code
Create a Lot of General-Purpose Code
Project-Specific Functionality
Simplilying an Existing Interface
Reshaping an Interface to Your Needs
Taking Things Too Far
Summary
ONETASK ATA TIME
Tasks Can Be Small
Extracting Values from an Object
A Larger Example
Summary
TURNING THOUGHTS INTO CODE
Describing Logic Clearly
Knowing Your Libraries Helps
Applying This Method to Larger Problems
Summary
WRITING LESS CODE
Don't Bother Implementing That Feature--You Won't Need It
Question and Break Douan Your Requirements
Keeping Your Codebase Small
Be Familiar with the Libraries Around You
Example: Using Unix Tools Itead of Coding
Summary
Part Four SELECTED TOPICS
TESTING AND READABILITY
Make Tests Easy to Read and Maintain
What's Wrong with This Test?
Making This Test More Readable
Making Error Messages Readable
Choosing Good Test Inputs
Naming Test Functio
What Was Wrong with That Test?
Test-Friendly Deuelopment
Going Too Far
Summary
DESIGNING AND IMPLEMENTING A "MINUTE/HOUR COUNTER"
The Problem
Defining the Class Interface
Attempt 1: A Naiue Solution
Attempt 2: Conueyor Belt Design
Attempt 3: A Time-Bucketed Design
Comparing the Three Solutio
Summary
FURTHER READING
INDEX

媒體關(guān)注與評論

  “意識到你所編寫的代碼如何影響他人的閱讀和理解是軟件開發(fā)中的一個重要環(huán)節(jié)。本書的作者通過大量啟發(fā)式的例子帶領(lǐng)讀者從多個不同的方面去迎接這一挑戰(zhàn),在這一領(lǐng)域做出了偉大的工作?!薄  狹ichael Hunger,軟件開發(fā)人員,Neo Technology

圖書封面

圖書標(biāo)簽Tags

評論、評分、閱讀與下載


    易讀代碼的藝術(shù) PDF格式下載


用戶評論 (總計(jì)10條)

 
 

  •   不錯的,就是買錯了,買了本純英文的
  •   讀這本書,感覺不太好,如果出版翻譯后的肯定會更受歡迎。排版不是很好,如果字體顏色鮮明會更好。
  •   對于初學(xué)者來說,書里面的內(nèi)容都是很有必要學(xué)習(xí)的,英語也都很直白易懂,推薦!
  •   對自己平時(shí)寫代碼又很好的參考價(jià)值,代碼的工整性
  •   寫得通俗易懂,對于實(shí)際應(yīng)用場景很實(shí)用,英文表達(dá)也很通俗,生動
  •   我覺得影印版應(yīng)該在多點(diǎn)。很給力啊。學(xué)習(xí)力英文,又能看到大神的思想。。
  •   很好很強(qiáng)大, 原本以為是 中文的 ~~
  •   內(nèi)容還不錯,適合提高代碼質(zhì)量
  •   內(nèi)容很不錯,很適合業(yè)內(nèi)人士閱讀,印刷也很清楚,這種書還是讀英文版的比較好
  •   關(guān)于代碼編寫提供了很有價(jià)值的一些建議,還是不錯的。
 

250萬本中文圖書簡介、評論、評分,PDF格式免費(fèi)下載。 第一圖書網(wǎng) 手機(jī)版

京ICP備13047387號-7