實(shí)現(xiàn)模式

出版時(shí)間:2008-11  出版社:人民郵電出版社  作者:Kent Beck  頁(yè)數(shù):157  
Tag標(biāo)簽:無(wú)  

前言

  這是一本關(guān)于如何寫(xiě)好代碼的書(shū)。?! ∪绻悴徽J(rèn)為寫(xiě)好代碼是一件重要。困難并且有趣的事,請(qǐng)立即放下這《實(shí)現(xiàn)模式》?! ∈裁词呛玫拇a?可以工作的。性能良好的。不出bug的代碼,就是好的代碼嗎?  所謂好的代碼,除了其他所有要求以外,還應(yīng)該清晰準(zhǔn)確地傳達(dá)寫(xiě)作者的想法?! artinFowler在《重構(gòu):改善既有代碼的設(shè)計(jì)》里說(shuō),“任何一個(gè)傻瓜都能寫(xiě)出機(jī)器能懂的代碼。好的程序員應(yīng)該寫(xiě)出人能懂的代碼?!薄 ∪绻悴煌膺@句話,請(qǐng)立即放下這《實(shí)現(xiàn)模式》。因?yàn)檫@是一本關(guān)于如何用代碼與他人(而非機(jī)

內(nèi)容概要

  在本書(shū)中,作者將自己多年形成的編程習(xí)慣以及閱讀既有代碼的體驗(yàn)?zāi)毘闪司幊讨械膬r(jià)值觀、原則和77種實(shí)現(xiàn)模式。  溝通、簡(jiǎn)單和靈活的價(jià)值觀應(yīng)當(dāng)被所有開(kāi)發(fā)人員所銘記。局部影響、最小化重復(fù)、將邏輯與數(shù)據(jù)捆綁等原則同樣是通用性的指導(dǎo)思想,比價(jià)值觀更貼近編程場(chǎng)景,在價(jià)值觀和模式之間搭建了橋梁。在77個(gè)實(shí)現(xiàn)模式中,每一個(gè)模式都覆蓋了編寫(xiě)簡(jiǎn)潔、清晰、易擴(kuò)展、易維護(hù)的代碼這一原則的某個(gè)方面。它們?yōu)槿粘5木幊烫峁┝素S富翔實(shí)的參考依據(jù),并告訴大家這些代碼如何為降低溝通成本和提高有效產(chǎn)出提供保障。  本書(shū)適用于各個(gè)階段的開(kāi)發(fā)者群體,剛剛涉足軟件開(kāi)發(fā)領(lǐng)域的新人能夠透過(guò)大師的眼睛來(lái)看待編程,了解編程的價(jià)值觀與原則;而具有豐富經(jīng)驗(yàn)的資深工程師則可以通過(guò)這些模式進(jìn)行反思,探究成功實(shí)踐背后的意義。把價(jià)值觀、原則和開(kāi)發(fā)實(shí)踐結(jié)合之后,日常開(kāi)發(fā)工作便會(huì)以嶄新迷人的形式呈現(xiàn)在我們面前。

書(shū)籍目錄

Chapter 1: Introduction 1 Tour Guide 3 And Now 4Chapter 2: Patterns 5Chapter 3: A Theory of Programming 9 Values 10  Communication 10  Simplicity 11  Flexibility 12 Principles 13  Local Consequences 13  Minimize Repetition 14  Logic and Data Together 14  Symmetry 15  Declarative Expression 16  Rate of Change 17 Conclusion 18Chapter 4: Motivation 19Chapter 5: Class 21 Class 22 Simple Superclass Name 23 Qualified Subclass Name 24 Abstract Interface 24 Interface 26 Abstract Class 26 Versioned Interface 27 Value Object 28 Specialization 31 Subclass 32 Implementor 34 Inner Class 34 Instance-Specific Behavior 36 Conditional 36 Delegation 38 Pluggable Selector 40 Anonymous Inner Class 41 Library Class 41 Conclusion 42Chapter 6: State 43 State 44 Access 45 Direct Access 46 Indirect Access 47 Common State 47 Variable State 48 Extrinsic State 50 Variable 50 Local Variable 51 Field 52 Parameter 53 Collecting Parameter 55 Optional Parameter 56 Var Args 56 Parameter Object 57 Constant 58 Role-Suggesting Name 58 Declared Type 60 Initialization 61 Eager Initialization 61 Lazy Initialization 62 Conclusion 62Chapter 7: Behavior 63 Control Flow 64 Main Flow 64 Message 65 Choosing Message 65 Double Dispatch 66 Decomposing (Sequencing) Message 67 Reversing Message 67 Inviting Message 68 Explaining Message 69 Exceptional Flow 70 Guard Clause 70 Exception 72 Checked Exceptions 72 Exception Propagation 73 Conclusion 73Chapter 8: Methods 75 Composed Method 77 Intention-Revealing Name 79 Method Visibility 80 Method Object 82 Overridden Method 83 Overloaded Method 83 Method Return Type 84 Method Comment 85 Helper Method 85 Debug Print Method 86 Conversion 87 Conversion Method 87 Conversion Constructor 88 Creation 88 Complete Constructor 89 Factory Method 90 Internal Factory 91 Collection Accessor Method 91 Boolean Setting Method 93 Query Method 93 Equality Method 94 Getting Method 95 Setting Method 96 Safe Copy 97 Conclusion 98Chapter 9: Collections 99 Metaphors 100 Issues 101 Interfaces 103  Array 103  Iterable 104  Collection 104  List 104  Set 105  SortedSet 105  Map 106 Implementations 107  Collection 108  List 108  Set 108  Map 109 Collections 110  Searching 111  Sorting 112  Unmodifiable Collections 113  Single-Element Collections 114  Empty Collections 114 Extending Collections 114 Conclusion 115Chapter 10: Evolving Frameworks 117 Changing Frameworks without Changing Applications117 Incompatible Upgrades 118 Encouraging Compatible Change 120  Library Class 121  Objects 121 Conclusion 129Appendix A: Performance Measurement 131 Example 131 API 132 Implementation 133 MethodTimer 134 Canceling Overhead 136 Tests 136  Comparing Collections 137  Comparing ArrayList and LinkedList 139  Comparing Sets 140  Comparing Maps 141 Conclusion 142Bibliography 145 General Programming 145 Philosophy 147 Java 148Index 149

章節(jié)摘錄

  Intro duction  Here we are together.You’ve picked up my book(its yours now).You akeady write code.You have probably already developed a style of your own through your own experiences.  The goal of this book is to help you communicate your intentions through your code.The book begins with an overview of programming and patterns (chapters 2-4).The remainder of the book(chapters 5-8)is a series of short essays,patterns,on how to use the features of Java to write readable code.It closes with a chapter on how to modif、r the advice here if you are writing frameworks instead of applications.Throughout,the book is focused on programming techniques that enhance communication.  There are several steps to communicating through code.First I had to become conscious while programming.I had been programming for years when I first started writing implementation patterns.1 was astonished to discover that,even though programming decisions came smoothly and quickly to me,I couldn’t explain why 1 was SO sure a method should be called such.a(chǎn)nd.SO or that a bit of logic belonged in this object over here.The first step towards communicating was slowing down long enough to become aware of what 1 was thinking,to stop pretending that I coded by instinct.  The second step was acknowledging the importance of other people.I found programming satislying,but I am self-centered.Before I could write communicative code I needed to believe that other people were as important as 1 was.Programming is hardly ever a solitary communion between one man and one machine.Caring about other people is a conscious decision,and one that requires practice.  Which brings me to the third step.Once I had exposed my thinking to sunlight and fresh air and acknowledged that other people had as much right to exist as I did,I needed to demonstrate my new perspective in practice.I use the implementation patterns here to program consciously and for others as well as myself.

編輯推薦

  在《實(shí)現(xiàn)模式》中,作者收集了77種模式,用于處理日常編程任務(wù)。編寫(xiě)可讀性更高的代碼。這個(gè)新的模式集合涵蓋了開(kāi)發(fā)中的諸多方面,包括類(lèi)、狀態(tài)、行為、方法、容器及框架等。圖表、故事、示例和隨筆的配合使用,使作者筆下的種種模式顯得異彩紛呈,從中可以發(fā)現(xiàn)許多經(jīng)受過(guò)實(shí)踐檢驗(yàn)的解決方案,小至變量命名,大到異常檢查?! ent BeCk,軟件業(yè)中最具創(chuàng)新力、最富盛名的領(lǐng)袖之一。長(zhǎng)期以來(lái)。他一直致力于挑戰(zhàn)軟件工程教條。推動(dòng)模式、測(cè)試驅(qū)動(dòng)開(kāi)發(fā)以及極限編程等思想的應(yīng)用和傳播。他是Three RIvers Institute的創(chuàng)始人和董事,也是Agitar Software的成員。他在AddiSOll一WesIev出版了多《實(shí)現(xiàn)模式》(英文版)籍,其中包括Test-Development(中譯版《測(cè)試驅(qū)動(dòng)開(kāi)發(fā)》)。以及與Cyrlthia Andres合著的EXtreme Programming,Explalined(中譯版《解析極限編程》)?!秾?shí)現(xiàn)模式》(英文版)包括以下內(nèi)容:  ·通過(guò)代碼進(jìn)行交流的重要性和隱藏在模式背后的思想;  ·何時(shí)創(chuàng)建類(lèi),如何創(chuàng)建類(lèi),類(lèi)又是怎樣書(shū)寫(xiě)邏輯的;  ·存儲(chǔ)和獲取狀態(tài)的最佳實(shí)踐;  ·行為,即用于表述邏輯(包括可選執(zhí)行路徑)的模式;  ·編寫(xiě)方法。為方法命名,以及對(duì)方法進(jìn)行分解;  ·選擇和使用容器;  ·實(shí)現(xiàn)模式在用于構(gòu)建框架時(shí)的變體。  “Kent是用代碼來(lái)溝通的大師,他的代碼條分縷析,明曉清晰,如益友攜手,如良師解惑,令人豁然開(kāi)朗?!薄  狤rich Gamma,IBM杰出工程師

圖書(shū)封面

圖書(shū)標(biāo)簽Tags

無(wú)

評(píng)論、評(píng)分、閱讀與下載


    實(shí)現(xiàn)模式 PDF格式下載


用戶評(píng)論 (總計(jì)4條)

 
 

  •   不僅內(nèi)容好而且印刷相當(dāng)?shù)陌?!每一張紙都很有手感,已經(jīng)讀完,經(jīng)典!!!
  •   非常不錯(cuò),對(duì)于初涉程序的人員來(lái)說(shuō),深入遷出的用具體實(shí)例來(lái)闡述了多種常用開(kāi)發(fā)模式,受益匪淺
  •   沒(méi)有模式基礎(chǔ),看比較累
  •   看不懂啊,放在書(shū)架上晾著……
 

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

京ICP備13047387號(hào)-7