大話設計模式【Java溢彩加強版】

程傑

  • 大話設計模式【Java溢彩加強版】-preview-1
  • 大話設計模式【Java溢彩加強版】-preview-2
  • 大話設計模式【Java溢彩加強版】-preview-3
大話設計模式【Java溢彩加強版】-preview-1

買這商品的人也買了...

相關主題

商品描述

《大話設計模式 Java溢彩加強版》是百萬銷量的經典暢銷書《大話設計模式》的全新升級版,描述語言由上一版C#變為Java。 《大話設計模式 Java溢彩加強版》在形式上開創了IT技術圖書的先河。通篇以情景對話形式,用多個小故事和編程示例來組織解讀GoF(設計模式經典名著—Design Patterns Elements of Reusable Object-Oriented Software)的23個設計模式。 《大話設計模式 Java溢彩加強版》共分為一個楔子+29章正文。其中,楔子主要通過一個編程實例的演變為初學者介紹了面向對象的基本概念,用來奠定面向對象基礎以及樹立正確的、有高度的開發思維;第0、1、3、4、5章著重講解了面向對象的意義、好處以及幾個重要的設計規則;第2章,以及第6~28章詳細講解了23種設計模式;第29章對設計模式進行了全面總結。 《大話設計模式 Java溢彩加強版》的特色是通過小菜與大鳥的趣味問答,在講解程序的不斷重構和演講過程中,極大地降低設計模式的學習門檻,讓初學者可以更加容易地理解為什麽這樣設計才是好的?是怎樣想到這樣設計的?以達到不但授之以“魚”,還授之以“漁”的目的,引導讀者體會設計演變過程中蘊藏的大智慧。

目錄大綱

目 錄

 

第0章 楔子 培訓實習生—面向對象基礎 ························1

 

0.1 培訓實習生 ·······························1

 

0.2 類與實例 ··································2

 

0.3 構造方法 ··································4

 

0.4 方法重載 ··································6

 

0.5 屬性與修飾符 ····························7

 

0.6 封裝 ········································9

 

0.7 繼承 ······································10

 

0.8 多態 ······································14

 

0.9 重構 ······································18

 

0.10 抽象類 ··································20

 

0.11 接口 ·····································22

 

0.12 集合 ·····································27

 

0.13 泛型 ·····································29

 

0.14 客套 ·····································31

 

第1章 代碼無錯就是優?—簡單工廠模式 ······················32

 

1.1 面試受挫 ································32

 

1.2 初學者代碼毛病 ·······················33

 

1.3 代碼規範 ································34

 

1.4 面向對象編程 ··························34

 

1.5 活字印刷,面向對象 ·················35

 

1.6 面向對象的好處 ·······················37

 

1.7 復制 vs. 復用····························37

 

1.8 業務的封裝 ·····························38

 

1.9 緊耦合 vs. 松耦合······················40

 

1.10 簡單工廠模式 ·························42

 

1.11 UML類圖 ······························43

 

第2章 商場促銷—策略模式 ········································48

 

2.1 商場收銀軟件 ··························48

 

2.2 增加打折 ································49

 

2.3 簡單工廠實現 ··························50

 

2.4 策略模式 ································53

 

2.5 策略模式實現 ··························55

 

2.6 策略與簡單工廠結合 ·················57

 

2.7 策略模式解析 ··························58

 

第3章 電子閱讀器 vs. 手機—單一職責原則 ···················60

 

3.1 閱讀乾嗎不直接用手機? ···········60

 

3.2 手機不純粹 ·····························60

 

 

 

XV

 

目 錄

 

3.3 電子閱讀器 vs. 手機···················61

 

3.4 單一職責原則 ··························62

 

3.5 方塊游戲的設計 ·······················62

 

3.6 電子閱讀器與手機的利弊 ···········65

 

第4章 考研求職兩不誤—開放-封閉原則 ························66

 

4.1 考研失敗 ································66

 

4.2 開放-封閉原則 ·························67

 

4.3 何時應對變化 ··························69

 

4.4 兩手準備,並全力以赴 ··············70

 

第5章 會修電腦不會修收音機?—依賴倒轉原則 ·············72

 

5.1 MM請求修電腦 ························72

 

5.2 電話遙控修電腦 ·······················73

 

5.3 依賴倒轉原則 ··························74

 

5.4 里氏代換原則 ··························77

 

5.5 修收音機 ································78

 

第6章 穿什麽有這麽重要?—裝飾模式 ·························80

 

6.1 穿什麽有這麽重要? ·················80

 

6.2 小菜扮靚第一版 ·······················81

 

6.3 小菜扮靚第二版 ·······················83

 

6.4 裝飾模式 ································85

 

6.5 小菜扮靚第三版 ·······················88

 

6.6 商場收銀程序再升級 ·················91

 

6.7 簡單工廠+策略+裝飾模式實現 ·····92

 

6.8 裝飾模式總結 ··························96

 

第7章 為別人做嫁衣—代理模式 ··································98

 

7.1 為別人做嫁衣! ·······················98

 

7.2 沒有代理的代碼 ······················100

 

7.3 只有代理的代碼 ······················101

 

7.4 符合實際的代碼 ······················102

 

7.5 代理模式 ·······························104

 

7.6 代理模式應用 ·························105

 

7.7 秀才讓小六代其求婚 ················106

 

第8章 工廠製造細節無須知—工廠方法模式 ·················107

 

8.1 需要瞭解工廠製造細節嗎? ·······107

 

8.2 簡單工廠模式實現 ···················108

 

8.3 工廠方法模式實現 ···················109

 

8.4 簡單工廠 vs. 工廠方法 ··············110

 

8.5 商場收銀程序再再升級 ·············115

 

8.6 簡單工廠+策略+裝飾+工廠方法 ··116

 

 

 

XVI

 

大話設計模式 | 【Java溢彩加強版】

 

第9章 簡歷復印—原型模式 ······································120

 

9.1 誇張的簡歷 ····························120

 

9.2 簡歷代碼初步實現 ···················121

 

9.3 原型模式 ·······························123

 

9.4 簡歷的原型實現 ······················125

 

9.5 淺復制與深復制 ······················126

 

9.6 簡歷的深復制實現 ···················129

 

9.7 復制簡歷 vs. 手寫求職信 ···········130

 

第10章 考題抄錯會做也白搭—模板方法模式 ···············132

 

10.1 選擇題不會做,蒙唄! ············132

 

10.2 重復=易錯+難改 ·····················133

 

10.3 提煉代碼 ······························135

 

10.4 模板方法模式 ························138

 

10.5 模板方法模式的特點 ···············140

 

10.6 主觀題,看你怎麽蒙 ···············140

 

第11章 無熟人難辦事?—迪米特法則 ························141

 

11.1 第一天上班 ···························141

 

11.2 無熟人難辦事 ························142

 

11.3 迪米特法則 ···························144

 

第12章 牛市股票還會虧錢?—外觀模式 ·····················145

 

12.1 牛市股票還會虧錢? ···············145

 

12.2 股民炒股代碼 ························146

 

12.3 投資基金代碼 ························147

 

12.4 外觀模式 ······························149

 

12.5 何時使用外觀模式 ··················150

 

第13章 好菜每回味不同—建造者模式 ························152

 

13.1 炒麵沒放鹽 ···························152

 

13.2 建造小人一 ···························154

 

13.3 建造小人二 ···························155

 

13.4 建造者模式 ···························156

 

13.5 建造者模式解析 ·····················159

 

13.6 建造者模式基本代碼 ···············160

 

第14章 老闆回來,我不知道—觀察者模式 ··················162

 

14.1 老闆回來?我不知道! ············162

 

14.2 雙向耦合的代碼 ·····················163

 

14.3 解耦實踐一 ···························165

 

14.4 解耦實踐二 ···························167

 

14.5 觀察者模式 ···························170

 

14.6 觀察者模式的特點 ··················172

 

 

 

14.7 Java內置接口實現 ···················173

 

14.8 觀察者模式的應用 ··················177

 

14.9 石守吉失手機後 ·····················178

 

第15章 就不能不換DB嗎?—抽象工廠模式 ·················179

 

15.1 就不能不換DB嗎? ·················179

 

15.2 最基本的數據訪問程序 ············181

 

15.3 用了工廠方法模式的數據訪問

 

 程序 ····································182

 

15.4 用了抽象工廠模式的數據訪問

 

 程序 ····································185

 

15.5 抽象工廠模式 ························188

 

15.6 抽象工廠模式的優點與缺點 ······189

 

15.7 用簡單工廠來改進抽象工廠 ······190

 

15.8 用反射+抽象工廠的數據訪問

 

 程序 ····································192

 

15.9 用反射+配置文件實現數據訪問

 

 程序 ····································194

 

15.10 商場收銀程序再再再升級 ·······195

 

15.11 無痴迷,不成功····················198

 

第16章 無盡加班何時休—狀態模式 ···························199

 

16.1 加班,又是加班! ··················199

 

16.2 工作狀態 — 函數版 ·············200

 

16.3 工作狀態 — 分類版 ·············201

 

16.4 方法過長是壞味道 ··················203

 

16.5 狀態模式 ······························203

 

16.6 狀態模式的好處與用處 ············205

 

16.7 工作狀態 — 狀態模式版 ·······206

 

第17章 在NBA我需要翻譯—適配器模式 ·····················209

 

17.1 在NBA我需要翻譯! ···············209

 

17.2 適配器模式 ···························210

 

17.3 何時使用適配器模式 ···············212

 

17.4 籃球翻譯適配器 ·····················213

 

17.5 適配器模式的.NET應用 ···········216

 

17.6 扁鵲的醫術 ···························217

 

第18章 如果再回到從前—備忘錄模式 ························218

 

18.1 如果再給我一次機會…… ·········218

 

18.2 游戲存進度 ···························219

 

18.3 備忘錄模式 ···························221

 

18.4 備忘錄模式基本代碼 ···············222

 

18.5 游戲進度備忘 ························224

 

 

 

大話設計模式 | 【Java溢彩加強版】

 

第19章 分公司=一部門—組合模式 ····························227

 

19.1 分公司不就是一部門嗎? ·········227

 

19.2 組合模式 ······························229

 

19.3 透明方式與安全方式 ···············231

 

19.4 何時使用組合模式 ··················232

 

19.5 公司管理系統 ························233

 

19.6 組合模式好處 ························235

 

第20章 想走?可以!先買票—迭代器模式 ··················237

 

20.1 乘車買票,不管你是誰! ·········237

 

20.2 迭代器模式 ···························239

 

20.3 迭代器實現 ···························240

 

20.4 Java的迭代器實現 ···················243

 

20.5 迭代高手 ······························244

 

第21章 有些類也需計劃生育—單例模式 ·····················245

 

21.1 類也需要計劃生育 ··················245

 

21.2 判斷對象是否是null ················246

 

21.3 生還是不生是自己的責任 ·········249

 

21.4 單例模式 ······························251

 

21.5 多線程時的單例 ·····················253

 

21.6 雙重鎖定 ······························254

 

21.7 靜態初始化 ···························255

 

第22章 手機軟件何時統一—橋接模式 ························257

 

22.1 憑什麽你的游戲我不能玩 ·········257

 

22.2 緊耦合的程序演化 ··················258

 

22.3 合成/聚合復用原則 ·················262

 

22.4 松耦合的程序 ························263

 

22.5 橋接模式 ······························265

 

22.6 橋接模式基本代碼 ··················267

 

22.7 我要開發“好”游戲 ···············268

 

第23章 烤羊肉串引來的思考—命令模式 ·····················269

 

23.1 吃烤羊肉串! ························269

 

23.2 燒烤攤 vs. 燒烤店 ···················270

 

23.3 緊耦合設計 ···························271

 

23.4 命令模式 ······························272

 

23.5 松耦合設計 ···························274

 

23.6 進一步改進命令模式 ···············276

 

23.7 命令模式的作用 ·····················278

 

 

 

第24章 加薪非要老總批?—職責鏈模式 ·····················279

 

24.1 老闆,我要加薪! ··················279

 

24.2 加薪代碼初步 ························280

 

24.3 職責鏈模式 ···························282

 

24.4 職責鏈的好處 ························284

 

24.5 加薪代碼重構 ························284

 

24.6 加薪成功 ······························287

 

第25章 世界需要和平—中介者模式 ···························289

 

25.1 世界需要和平! ·····················289

 

25.2 中介者模式 ···························291

 

25.3 安理會作中介 ························293

 

25.4 中介者模式的優缺點 ···············295

 

第26章 項目多也別傻做—享元模式 ···························298

 

26.1 項目多也別傻做! ··················298

 

26.2 享元模式 ······························300

 

26.3 網站共享代碼 ························302

 

26.4 內部狀態與外部狀態 ···············304

 

26.5 享元模式應用 ························306

 

第27章 其實你不懂老闆的心—解釋器模式 ··················309

 

27.1 其實你不懂老闆的心 ···············309

 

27.2 解釋器模式 ···························310

 

27.3 解釋器模式的好處 ··················313

 

27.4 音樂解釋器 ···························313

 

27.5 音樂解釋器實現 ·····················315

 

27.6 料事如神 ······························319

 

第28章 男人和女人—訪問者模式 ······························320

 

28.1 男人和女人! ························320

 

28.2 最簡單的編程實現 ··················321

 

28.3 簡單的面向對象實現 ···············322

 

28.4 用了模式的實現 ·····················324

 

28.5 訪問者模式 ···························327

 

28.6 訪問者模式基本代碼 ···············328

 

28.7 比上不足,比下有餘 ···············330

 

第29章 OOTV杯超級模式大賽—模式總結 ···················331

 

29.1 演講任務 ······························331

 

29.2 報名參賽 ······························332

 

29.3 超模大賽開幕式 ·····················333

 

29.4 創建型模式比賽 ·····················337

 

 

 

29.5 結構型模式比賽 ·····················342

 

29.6 行為型模式一組比賽 ···············350

 

29.7 行為型模式二組比賽 ···············356

 

29.8 決賽 ····································361

 

29.9 夢醒時分 ······························365

 

29.10 沒有結束的結尾 ···················366

 

參考文獻···································································367