碼農(nóng)修行:編寫(xiě)優(yōu)雅代碼的32條法則
定 價(jià):99 元
- 作者:林文 著
- 出版時(shí)間:2020/8/1
- ISBN:9787111660392
- 出 版 社:機(jī)械工業(yè)出版社
- 中圖法分類:TP311.52
- 頁(yè)碼:280
- 紙張:
- 版次:
- 開(kāi)本:16開(kāi)
如何打造精品軟件一直是軟件行業(yè)討論的熱點(diǎn)話題。初入職場(chǎng)的軟件開(kāi)發(fā)人員,多數(shù)都只是在學(xué)會(huì)了某種編程語(yǔ)言后就直接進(jìn)行編程工作。但由于他們并未掌握編程中的一些有效方法,導(dǎo)致其開(kāi)發(fā)的軟件問(wèn)題累累且工作效率不高。碼農(nóng)修行 編寫(xiě)優(yōu)雅代碼的32條法則針對(duì)這類人群提出了一些改善編程方法的建議,涉及具體編程工作的諸多方面,偏重于實(shí)踐。書(shū)中大部分示例都是筆者實(shí)際編程工作中碰到過(guò)的真實(shí)案例,具有較高的參考價(jià)值。碼農(nóng)修行 編寫(xiě)優(yōu)雅代碼的32條法則從代碼的可讀性、可靠性、效率、可維護(hù)性、可擴(kuò)展性5個(gè)方面,提出了編寫(xiě)代碼的32 條法則。此外還公開(kāi)了筆者自主編寫(xiě)的一款A(yù)ndroid 小游戲源代碼,希望能對(duì)讀者有所幫助。
碼農(nóng)修行 編寫(xiě)優(yōu)雅代碼的32條法則適用于有一定編程基礎(chǔ)、且想進(jìn)一步提升個(gè)人編程能力的讀者閱讀,也可作為大中專院校計(jì)算機(jī)專業(yè)師生的教學(xué)參考用書(shū)。
自序
前言
引子 ···································································································· 1
第1 章:可讀性 ························································································· 4
法則01:準(zhǔn)確命名 ·············································································· 6
法則02:設(shè)置縮進(jìn) ············································································ 12
法則03:保留個(gè)性 ············································································ 16
法則04:語(yǔ)法潛臺(tái)詞 ········································································ 21
法則05:補(bǔ)充注釋 ············································································ 26
第2 章:可靠性 ······················································································· 37
法則06:增強(qiáng)健壯性 ········································································ 39
法則07:避免過(guò)度防御 ···································································· 43
法則08:防止不確定性 ···································································· 48
法則09:善始善終 ············································································ 51
法則10:異常處理 ············································································ 59
法則11:留意編譯告警 ···································································· 65
法則12:盡早暴露問(wèn)題 ···································································· 67
法則13:規(guī)避短板 ············································································ 70
第3 章:效率 ··························································································· 75
法則14:關(guān)注性能熱點(diǎn) ···································································· 77
法則15:留意非熱點(diǎn)代碼 ································································· 84
法則16:采用緩存 ············································································ 90
法則17:引入并發(fā) ············································································ 99
第4 章:可維護(hù)性 ················································································· 102
法則18:記錄日志 ·········································································· 104
法則19:明確錯(cuò)誤提示 ·································································· 109
法則20:代碼看護(hù) ·········································································· 112
法則21:消除冗余代碼 ·································································· 117
法則22:掌握邏輯運(yùn)算 ·································································· 123
法則23:控制函數(shù)規(guī)模 ·································································· 128
法則24:控制文件規(guī)模 ·································································· 140
第5 章:可擴(kuò)展性 ················································································· 143
法則25:正確理解面向?qū)ο笤O(shè)計(jì) ···················································· 145
法則26:控制接口規(guī)模 ·································································· 155
法則27:寫(xiě)可重用的模塊 ······························································· 160
法則28:寫(xiě)可重入的函數(shù) ······························································· 164
法則29:避免循環(huán)依賴 ·································································· 169
法則30:保障平穩(wěn)升級(jí) ·································································· 176
法則31:靈活注入對(duì)象 ·································································· 182
法則32:正確運(yùn)用依賴注入 ··························································· 194
第6 章:代碼資源 ················································································· 200
日志框架 ························································································· 201
進(jìn)程委托調(diào)用框架··········································································· 208
花樣泡泡龍 ····················································································· 215
尾聲 ······································································································· 267