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