重構 改善既有代碼的設計(第2版·英文版)
作 者: (美)馬丁·福勒(Martin Fowler) 著
定 價: 128
出?版?社: 人民郵電出版社
出版日期: 2019年05月01日
頁 數: 407
裝 幀: 平裝
ISBN: 9787115510082
●Chapter 1:Refactoring:A First Example/重構,個示例1
TheStarting Point/起點1
Commentson the Starting Program/對此起始程序的評價3
TheFirst Step in Refactoring/重構的步5
Decomposingthe statement Function/分解statement方法6
Status:Lots of Nested Functions/進展:大量嵌套函數22
Splittingthe Phases of Calculation and Formatting/拆分計算階段與格式化階段24
Status:Separated into Two Files (and Phases)/進展:分離到兩個文件(和兩個階段)31
Reorganizingthe Calculations by Type/按類型重組計算過程34
Status:Creating the Data with the Polymorphic Calculator/進展:使用多態計算器來提供數據41
FinalThoughts/結語43
Chapter 2:Principles in Refactoring/重構的原則45
DefiningRefactoring/何謂重構45
TheTwo Hats/兩頂帽子46
WhyShould We Refactor/為何重構47
WhenShould We Refactor/何時重構50
Problemswith Refactoring/重構的挑戰55
Refactoring,Architecture, and Yagni/重構、架構和YAGNI62
Refactoringand the Wider Software Development Process/重構與軟件開發過程63
Refactoringand Performance/重構與性能64
WhereDid Refactoring Come From/重構起源何處67
AutomatedRefactorings/自動化重構68
GoingFurther/延展閱讀70
Chapter3:Bad Smells in Code/代碼的壞味道71
MysteriousName/神秘命名72
DuplicatedCode/重復代碼72
LongFunction/過長函數73
LongParameter List/過長參數列表74
GlobalData/全局數據74
MutableData/可變數據75
DivergentChange/發散式變化76
ShotgunSurgery/霰彈式修改76
FeatureEnvy/依戀情結77
DataClumps/數據泥團78
PrimitiveObsession/基本類型偏執78
RepeatedSwitches/重復的switch79
Loops/循環語句79
LazyElement/素80
SpeculativeGenerality/誇誇其談通用性80
TemporaryField/臨時字段80
MessageChains/過長的消息鏈81
MiddleMan/中間人81
InsiderTrading/內幕交易82
LargeClass/過大的類82
AlternativeClasses with Different Interfaces/異曲同工的類83
DataClass/純數據類83
RefusedBequest/被拒絕的遺贈83
Comments/注釋84
Chapter4:Building Tests/構築測試體繫85
TheValue of Self-Testing Code/自測試代碼的價值85
SampleCode to Test/待測試的樣例代碼87
AFirst Test/個測試90
AddAnother Test/再添加一個測試93
Modifyingthe Fixture/修改測試夾具95
Probingthe Boundaries/探測邊界條件96
MuchMore Than This/測試遠不止如此99
Chapter5:Introducing the Catalog/介紹重構名錄101
Formatof the Refactorings/重構的記錄格式101
TheChoice of Refactorings/挑選重構的依據102
Chapter6:A First Set of Refactorings/組重構105
ExtractFunction/提煉函數106
InlineFunction/內聯函數115
ExtractVariable/提煉變量119
InlineVariable/內聯變量123
ChangeFunction Declaration/改變函數聲明124
EncapsulateVariable/封裝變量132
RenameVariable/變量改名137
IntroduceParameter Object/引入參數對像140
CombineFunctions into Class/函數組合成類144
CombineFunctions into Transform/函數組合成變換149
SplitPhase/拆分階段154
Chapter7:Encapsulation/封裝161
EncapsulateRecord/封裝記錄162
EncapsulateCollection/封裝集合170
ReplacePrimitive with Object/以對像取代基本類型174
ReplaceTemp with Query/以查詢取代臨時變量178
ExtractClass/提煉類182
InlineClass/內聯類186
HideDelegate/隱藏委托關繫189
RemoveMiddle Man/移除中間人192
SubstituteAlgorithm/替換算法195
Chapter8:Moving Features/搬移特性197
MoveFunction/搬移函數198
MoveField/搬移字段207
MoveStatements into Function/搬移語句到函數213
MoveStatements to Callers/搬移語句到調用者217
ReplaceInline Code with Function Call/以函數調用取代內聯代碼222
SlideStatements/移動語句223
SplitLoop/拆分循環227
ReplaceLoop with Pipeline/以管道取代循環231
RemoveDead Code/移除死代碼237
Chapter9:Organizing Data/重新組織數據239
SplitVariable/拆分變量240
RenameField/字段改名244
ReplaceDerived Variable with Query/以查詢取代派生變量248
ChangeReference to Value/將引用對像改為值對像252
ChangeValue to Reference/將值對像改為引用對像256
Chapter10:Simplifying Conditional Logic/簡化條件邏輯259
DecomposeConditional/分解條件表達式260
ConsolidateConditional Expression/合並條件表達式263
ReplaceNested Conditional with Guard Clauses/以衛語句取代嵌套條件表達式266
ReplaceConditional with Polymorphism/以多態取代條件表達式272
IntroduceSpe Case/引入特例289
IntroduceAssertion/引入斷言302
Chapter11:Refactoring APIs/重構API305
SeparateQuery from Modifier/將查詢函數和修改函數分離306
ParameterizeFunction/函數參數化310
RemoveFlag Argument/移除標記參數314
PreserveWhole Object/保持對像完整319
ReplaceParameter with Query/以查詢取代參數324
ReplaceQuery with Parameter/以參數取代查詢327
RemoveSetting Method/移除設值函數331
ReplaceConstructor with Factory Function/以工廠函數取代構造函數334
ReplaceFunction with Command/以命令取代函數337
ReplaceCommand with Function/以函數取代命令344
Chapter12:Dealing with Inheritance/處理繼承關繫349
PullUp Method/函數上移350
PullUp Field/字段上移353
PullUp Constructor Body/構造函數本體上移355
PushDown Method/函數下移359
PushDown Field/字段下移361
ReplaceType Code with Subclasses/以子類取代類型碼362
RemoveSubclass/移除子類369
ExtractSuperclass/提煉超類375
CollapseHierarchy/折疊繼承體繫380
ReplaceSubclass with Delegate/以委托取代子類381
ReplaceSuperclass with Delegate/以委托取代超類399
Bibliography/參考文獻405
內容簡介
本書是經典著作《重構》出版20年後的新版。書中清晰揭示了重構的過程,解釋了重構的原理和很好實踐方式,並給出了何時以及何地應該開始挖掘代碼以求改善。書中給出了60多個可行的重構,每個重構都介紹了一種經過驗證的代碼變換手法的動機和技術。本書提出的重構準則將幫助開發人員一次一小步地修改代碼,從而減少了開發過程中的風險。本書適合軟件開發人員、項目管理人員等閱讀,也可作為高等院校計算機及相關專業師生的參考讀物。
(美)馬丁·福勒(Martin Fowler) 著
馬丁·福勒(Martin Fowler) 軟件開發大師,ThoughtWorks的科學家。他是一位作家、演說者、咨詢師和泛軟件開發領域的意見ling袖。他致力於改善企業級的軟件設計,對設計以及支撐設計的工程實踐孜孜以求。他在重構、面向對像分析設計、模式、XP和UML等領域都有貢獻。著有《重構:改善既有代碼的設計》《分析模式》《領域特定語言》等經典著作。
"