實現(xiàn)模式

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

前言

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

內(nèi)容概要

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

書籍目錄

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.

編輯推薦

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

圖書封面

圖書標(biāo)簽Tags

評論、評分、閱讀與下載


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


用戶評論 (總計4條)

 
 

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

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

京ICP備13047387號-7