CS-Notes/notes/重构.md

980 lines
33 KiB
Markdown
Raw Normal View History

2018-02-22 01:06:40 +08:00
<!-- GFM-TOC -->
2018-02-22 14:47:54 +08:00
* [<EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD> <20><>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>](#<23><>һ<EFBFBD><D2BB>-<2D><>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
* [<EFBFBD>ڶ<EFBFBD><EFBFBD><EFBFBD> <20>ع<EFBFBD>ԭ<EFBFBD><D4AD>](#<23>ڶ<EFBFBD><DAB6><EFBFBD>-<2D>ع<EFBFBD>ԭ<EFBFBD><D4AD>)
* [<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ļ<EFBFBD>ζ<EFBFBD><CEB6>](#<23><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>-<2D><><EFBFBD><EFBFBD><EFBFBD>Ļ<EFBFBD>ζ<EFBFBD><CEB6>)
* [1. Duplicated Code<64><65><EFBFBD>ظ<EFBFBD><D8B8><EFBFBD><EFBFBD>](#1-duplicated-code<64>ظ<EFBFBD><D8B8><EFBFBD><EFBFBD><EFBFBD>)
* [2. Long Method<6F><64><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>](#2-long-method<6F><64><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
* [3. Large Class<73><73><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>](#3-large-class<73><73><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
* [4. Long Parameter List<73><74><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IJ<EFBFBD><C4B2><EFBFBD><EFBFBD>У<EFBFBD>](#4-long-parameter-list<73><74><EFBFBD><EFBFBD><EFBFBD>IJ<EFBFBD><C4B2><EFBFBD><EFBFBD><EFBFBD>)
* [5. Divergent Change<67><65><EFBFBD><EFBFBD>ɢʽ<C9A2><EFBFBD><E4BBAF>](#5-divergent-change<67><65>ɢʽ<C9A2>)
* [6. Shotgun Surgery<72><79>ɢ<EFBFBD><C9A2>ʽ<EFBFBD>޸ģ<DEB8>](#6-shotgun-surgeryɢ<79><C9A2>ʽ<EFBFBD>޸<EFBFBD>)
* [7. Feature Envy<76><79><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>](#7-feature-envy<76><79><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
* [8. Data Clumps<70><73><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ţ<EFBFBD>](#8-data-clumps<70><73><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
* [9. Primitive Obsession<6F><6E><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƫִ<C6AB><D6B4>](#9-primitive-obsession<6F><6E><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƫִ)
* [10. Switch Statements<74><73>switch <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>](#10-switch-statementsswitch-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
* [11. Parallel Inheritance Hierarchies<65><73>ƽ<EFBFBD>м̳<D0BC><CCB3><EFBFBD>ϵ<EFBFBD><CFB5>](#11-parallel-inheritance-hierarchiesƽ<73>м̳<D0BC><CCB3><EFBFBD>ϵ)
* [12. Lazy Class<73><73><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>](#12-lazy-class<73><73><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
* [13. Speculative Generality<74><79><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD≯δ<CCB8><CEB4><EFBFBD>ԣ<EFBFBD>](#13-speculative-generality<74><79><EFBFBD><EFBFBD><EFBFBD><EFBFBD≯δ<CCB8><CEB4><EFBFBD><EFBFBD>)
* [14. Temporary Field<6C><64><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ի<EFBFBD><D4BB><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>ֶΣ<D6B6>](#14-temporary-field<6C><64><EFBFBD><EFBFBD><EFBFBD>Ի<EFBFBD><D4BB><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>ֶ<EFBFBD>)
* [15. Message Chains<6E><73><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD><CFB5><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>](#15-message-chains<6E><73><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD><CFB5><EFBFBD>Ϣ<EFBFBD><CFA2>)
* [16. Middle Man<61><6E><EFBFBD>м<EFBFBD><D0BC>ˣ<EFBFBD>](#16-middle-man<61>м<EFBFBD><D0BC><EFBFBD>)
* [17. Inappropriate Intimacy<63><79><EFBFBD><EFBFBD><EFBFBD>ǹ<EFBFBD>ϵ<EFBFBD><CFB5>](#17-inappropriate-intimacy<63><79><EFBFBD>ǹ<EFBFBD>ϵ)
* [18. Alernative Classes with Different Interfaces<65><73><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD><EFBFBD>](#18-alernative-classes-with-different-interfaces<65><73><EFBFBD><EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
* [19. Incomplete Library Class<73><73><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>](#19-incomplete-library-class<73><73><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
* [20. Data Class<73><73><EFBFBD><EFBFBD><EFBFBD>ɵ<EFBFBD><C9B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>](#20-data-class<73><73><EFBFBD>ɵ<EFBFBD><C9B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
* [21. Refused Bequest<73><74><EFBFBD><EFBFBD><EFBFBD>ܾ<EFBFBD><DCBE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>](#21-refused-bequest<73><74><EFBFBD>ܾ<EFBFBD><DCBE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
* [22. Comments<74><73><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD>ͣ<EFBFBD>](#22-comments<74><73><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><D7A2>)
* [<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵ](#<23><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵ)
* [<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ع<EFBFBD><D8B9>б<EFBFBD>](#<23><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>-<2D>ع<EFBFBD><D8B9>б<EFBFBD>)
* [<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֯<EFBFBD><D6AF><EFBFBD><EFBFBD>](#<23><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֯<EFBFBD><D6AF><EFBFBD><EFBFBD>)
* [1. Extract Method<6F><64><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>](#1-extract-method<6F><64><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
* [2. Inline Method<6F><64><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>](#2-inline-method<6F><64><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
* [3. Inline Temp<6D><70><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>](#3-inline-temp<6D><70><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>)
* [4. Replace Temp with Query<72><79><EFBFBD>Բ<EFBFBD>ѯȡ<D1AF><C8A1><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>](#4-replace-temp-with-query<72>Բ<EFBFBD>ѯȡ<D1AF><C8A1><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>)
* [5. Introduce Explaining Variable<6C><65><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͱ<EFBFBD><CDB1><EFBFBD><EFBFBD><EFBFBD>](#5-introduce-explaining-variable<6C><65><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͱ<EFBFBD><CDB1><EFBFBD>)
* [6. Split Temporary Variable<6C><65><EFBFBD>ֽ<EFBFBD><D6BD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>](#6-split-temporary-variable<6C>ֽ<EFBFBD><D6BD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>)
* [7. Remove Assigments to Parameters<72><73><EFBFBD>Ƴ<EFBFBD><C6B3>Բ<EFBFBD><D4B2><EFBFBD><EFBFBD>ĸ<EFBFBD>ֵ<EFBFBD><D6B5>](#7-remove-assigments-to-parameters<72>Ƴ<EFBFBD><C6B3>Բ<EFBFBD><D4B2><EFBFBD><EFBFBD>ĸ<EFBFBD>ֵ)
* [8. Replace Method with Method Object<63><74><EFBFBD>Ժ<EFBFBD><D4BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>](#8-replace-method-with-method-object<63>Ժ<EFBFBD><D4BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
* [9. Subsititute Algorithn<68><6E><EFBFBD><EFBFBD><EFBFBD><E3B7A8>](#9-subsititute-algorithn<68><EFBFBD>)
* [<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ڶ<EFBFBD><DAB6><EFBFBD>֮<EFBFBD><D6AE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>](#<23><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>-<2D>ڶ<EFBFBD><DAB6><EFBFBD>֮<EFBFBD><D6AE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
* [1. Move Method<6F><64><EFBFBD><EFBFBD><EFBFBD>ƺ<EFBFBD><C6BA><EFBFBD><EFBFBD><EFBFBD>](#1-move-method<6F><64><EFBFBD>ƺ<EFBFBD><C6BA><EFBFBD>)
* [2. Move Field<6C><64><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶΣ<D6B6>](#2-move-field<6C><64><EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD>)
* [3. Extract Class<73><73><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>](#3-extract-class<73><73><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
* [4. Inline Class<73><73><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>](#4-inline-class<73><73><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
* [5. Hide Delegate<74><65><EFBFBD><EFBFBD><EFBFBD>ء<EFBFBD>ί<EFBFBD>й<EFBFBD>ϵ<EFBFBD><CFB5><EFBFBD><EFBFBD>](#5-hide-delegate<74><65><EFBFBD>ء<EFBFBD>ί<EFBFBD>й<EFBFBD>ϵ<EFBFBD><CFB5>)
* [6. Remove Middle Man<61><6E><EFBFBD>Ƴ<EFBFBD><C6B3>м<EFBFBD><D0BC>ˣ<EFBFBD>](#6-remove-middle-man<61>Ƴ<EFBFBD><C6B3>м<EFBFBD><D0BC><EFBFBD>)
* [7. Introduce Foreign Method<6F><64><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӻ<EFBFBD><D3BA><EFBFBD><EFBFBD><EFBFBD>](#7-introduce-foreign-method<6F><64><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӻ<EFBFBD><D3BA><EFBFBD>)
* [8. Introduce Local Extension<6F><6E><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EBB1BE><EFBFBD><EFBFBD>չ<EFBFBD><D5B9>](#8-introduce-local-extension<6F><6E><EFBFBD><EFBFBD><EBB1BE><EFBFBD><EFBFBD>չ)
* [<EFBFBD>ڰ<EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֯<EFBFBD><D6AF><EFBFBD><EFBFBD>](#<23>ڰ<EFBFBD><DAB0><EFBFBD>-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֯<EFBFBD><D6AF><EFBFBD><EFBFBD>)
* [1. Self Encapsulate Field<6C><64><EFBFBD>Է<EFBFBD>װ<EFBFBD>ֶΣ<D6B6>](#1-self-encapsulate-field<6C>Է<EFBFBD>װ<EFBFBD>ֶ<EFBFBD>)
* [2. Replace Data Value with Object<63><74><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5>](#2-replace-data-value-with-object<63>Զ<EFBFBD><D4B6><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ)
* [3. Change Value to Reference<63><65><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD>ij<EFBFBD><C4B3><EFBFBD><EFBFBD>ö<EFBFBD><C3B6><EFBFBD><EFBFBD><EFBFBD>](#3-change-value-to-reference<63><65>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD>ij<EFBFBD><C4B3><EFBFBD><EFBFBD>ö<EFBFBD><C3B6><EFBFBD>)
* [4. Change Reference to value<75><65><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ö<EFBFBD><C3B6><EFBFBD><EFBFBD><EFBFBD>Ϊֵ<CEAA><D6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>](#4-change-reference-to-value<75><65><EFBFBD><EFBFBD><EFBFBD>ö<EFBFBD><C3B6><EFBFBD><EFBFBD><EFBFBD>Ϊֵ<CEAA><D6B5><EFBFBD><EFBFBD>)
* [5. Replace Array with Object<63><74><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD>](#5-replace-array-with-object<63>Զ<EFBFBD><D4B6><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
* [6. Duplicate Observed Data<74><61><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݡ<EFBFBD><DDA1><EFBFBD>](#6-duplicate-observed-data<74><61>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݡ<EFBFBD>)
* [7. Change Unidirectional Association to Bidirectional<61><6C><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ˫<CEAA><CBAB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>](#7-change-unidirectional-association-to-bidirectional<61><6C><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ˫<CEAA><CBAB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
* [8. Change Bidirectional Association to Unidirectional<61><6C><EFBFBD><EFBFBD>˫<EFBFBD><CBAB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>](#8-change-bidirectional-association-to-unidirectional<61><6C>˫<EFBFBD><CBAB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
* [9. Replace Magic Number with Symbolic Constant<6E><74><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E6B3A3>ȡ<EFBFBD><C8A1>ħ<EFBFBD><C4A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>](#9-replace-magic-number-with-symbolic-constant<6E><74><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E6B3A3>ȡ<EFBFBD><C8A1>ħ<EFBFBD><C4A7><EFBFBD><EFBFBD>)
* [10. Encapsulate Field<6C><64><EFBFBD><EFBFBD>װ<EFBFBD>ֶΣ<D6B6>](#10-encapsulate-field<6C><64>װ<EFBFBD>ֶ<EFBFBD>)
* [11. Encapsulate Collection<6F><6E><EFBFBD><EFBFBD>װ<EFBFBD><D7B0><EFBFBD>ϣ<EFBFBD>](#11-encapsulate-collection<6F><6E>װ<EFBFBD><D7B0><EFBFBD><EFBFBD>)
* [12. Replace Record with Data Class<73><73><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>¼<EFBFBD><C2BC>](#12-replace-record-with-data-class<73><73><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>¼)
* [13. Replace Type Code with Class<73><73><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>](#13-replace-type-code-with-class<73><73><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
* [14. Replace Type Code with Subcalsses<65><73><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>](#14-replace-type-code-with-subcalsses<65><73><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
* [15. Replace Type Code with State/Strategy <20><><EFBFBD><EFBFBD> State/Strategy ȡ<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>](#15-replace-type-code-with-statestrategy-<2D><>-statestrategy-ȡ<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
* [16. Replace Subclass with Fields<64><73><EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD>](#16-replace-subclass-with-fields<64><73><EFBFBD>ֶ<EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
* [<EFBFBD>ھ<EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ](#<23>ھ<EFBFBD><DABE><EFBFBD>-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ)
* [1. Decompose Conditional<61><6C><EFBFBD>ֽ<EFBFBD><D6BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><CABD>](#1-decompose-conditional<61>ֽ<EFBFBD><D6BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ)
* [2. Consolidate Conditional Expression<6F><6E><EFBFBD>ϲ<EFBFBD><CFB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><CABD>](#2-consolidate-conditional-expression<6F>ϲ<EFBFBD><CFB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ)
* [3. Consolidate Duplicate Conditional Fragments <20><><EFBFBD>ϲ<EFBFBD><CFB2>ظ<EFBFBD><D8B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƭ<EFBFBD>Σ<EFBFBD>](#3-consolidate-duplicate-conditional-fragments-<2D>ϲ<EFBFBD><CFB2>ظ<EFBFBD><D8B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƭ<EFBFBD><C6AC>)
* [4. Remove Control Flag<61><67><EFBFBD>Ƴ<EFBFBD><C6B3><EFBFBD><EFBFBD>Ʊ<EFBFBD><C6B1>ǣ<EFBFBD>](#4-remove-control-flag<61>Ƴ<EFBFBD><C6B3><EFBFBD><EFBFBD>Ʊ<EFBFBD><C6B1><EFBFBD>)
* [5. Replace Nested Conditional with Guard Clauses <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1>Ƕ<EFBFBD><C7B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><CABD>](#5-replace-nested-conditional-with-guard-clauses-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1>Ƕ<EFBFBD><C7B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ)
* [6. Replace Conditional with Polymorphism <20><><EFBFBD>Զ<EFBFBD>̬ȡ<CCAC><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><CABD>](#6-replace-conditional-with-polymorphism-<2D>Զ<EFBFBD>̬ȡ<CCAC><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ)
* [7. Introduce Null Object<63><74><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Null<6C><6C><EFBFBD><EFBFBD><EFBFBD><EFBFBD>](#7-introduce-null-object<63><74><EFBFBD><EFBFBD>null<6C><6C><EFBFBD><EFBFBD>)
* [8. Introduce Assertion<6F><6E><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԣ<EFBFBD>](#8-introduce-assertion<6F><6E><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
* [<EFBFBD><EFBFBD>ʮ<EFBFBD><EFBFBD> <20>򻯺<EFBFBD><F2BBAFBA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>](#<23><>ʮ<EFBFBD><CAAE>-<2D>򻯺<EFBFBD><F2BBAFBA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
* [1. Rename Method<6F><64><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>](#1-rename-method<6F><64><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
* [2. Add Parameter<65><72><EFBFBD><EFBFBD><EFBFBD>Ӳ<EFBFBD><D3B2><EFBFBD><EFBFBD><EFBFBD>](#2-add-parameter<65><72><EFBFBD>Ӳ<EFBFBD><D3B2><EFBFBD>)
* [3. Remove Parameter<65><72><EFBFBD>Ƴ<EFBFBD><C6B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>](#3-remove-parameter<65>Ƴ<EFBFBD><C6B3><EFBFBD><EFBFBD><EFBFBD>)
* [4. Separate Query from Modifier<65><72><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>޸ĺ<DEB8><C4BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>](#4-separate-query-from-modifier<65><72><EFBFBD><EFBFBD>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>޸ĺ<DEB8><C4BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
* [5. Parameterize Method<6F><64><EFBFBD><EFBFBD><EEBAAF>Я<EFBFBD><D0AF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>](#5-parameterize-method<6F><EFBFBD><EEBAAF>Я<EFBFBD><D0AF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
* [6. Replace Parameter with Explicit Methods<64><73><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȷ<EFBFBD><C8B7><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>](#6-replace-parameter-with-explicit-methods<64><73><EFBFBD><EFBFBD>ȷ<EFBFBD><C8B7><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
* [7. Preserve Whole Object<63><74><EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD><D6B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>](#7-preserve-whole-object<63><74><EFBFBD>ֶ<EFBFBD><D6B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
* [8. Replace Parameter with Methods<64><73><EFBFBD>Ժ<EFBFBD><D4BA><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>](#8-replace-parameter-with-methods<64>Ժ<EFBFBD><D4BA><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
* [9. Introduce Parameter Object<63><74><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>](#9-introduce-parameter-object<63><74><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
* [10. Remove Setting Method<6F><64><EFBFBD>Ƴ<EFBFBD><C6B3><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>](#10-remove-setting-method<6F>Ƴ<EFBFBD><C6B3><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD>)
* [11. Hide Method<6F><64><EFBFBD><EFBFBD><EFBFBD>غ<EFBFBD><D8BA><EFBFBD><EFBFBD><EFBFBD>](#11-hide-method<6F><64><EFBFBD>غ<EFBFBD><D8BA><EFBFBD>)
* [12. Replace Constructor with Factory Method <20><><EFBFBD>Թ<EFBFBD><D4B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><ECBAAF><EFBFBD><EFBFBD>](#12-replace-constructor-with-factory-method-<2D>Թ<EFBFBD><D4B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><ECBAAF>)
* [13. Encapsulate Downcast<73><74><EFBFBD><EFBFBD>װ<EFBFBD><D7B0><EFBFBD><EFBFBD>ת<EFBFBD>ͣ<EFBFBD>](#13-encapsulate-downcast<73><74>װ<EFBFBD><D7B0><EFBFBD><EFBFBD>ת<EFBFBD><D7AA>)
* [14. Replace Error Code with Exception <20><><EFBFBD><EFBFBD><EFBFBD>쳣ȡ<ECB3A3><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>](#14-replace-error-code-with-exception-<2D><><EFBFBD>쳣ȡ<ECB3A3><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
* [15. Replace Exception with Test<73><74><EFBFBD>Բ<EFBFBD><D4B2><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><ECB3A3>](#15-replace-exception-with-test<73>Բ<EFBFBD><D4B2><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD>)
* [<EFBFBD><EFBFBD>ʮһ<EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵ](#<23><>ʮһ<CAAE><D2BB>-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵ)
* [1. Pull Up Field<6C><64><EFBFBD>ֶ<EFBFBD><D6B6><EFBFBD><EFBFBD>ƣ<EFBFBD>](#1-pull-up-field<6C>ֶ<EFBFBD><D6B6><EFBFBD><EFBFBD><EFBFBD>)
* [2. Pull Up Method<6F><64><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƣ<EFBFBD>](#2-pull-up-method<6F><64><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
* [3. Pull Up Constructor Body<64><79><EFBFBD><EFBFBD><EFBFBD><EFBFBD><ECBAAF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƣ<EFBFBD>](#3-pull-up-constructor-body<64><79><EFBFBD><EFBFBD><ECBAAF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
* [4. Push Down Method<6F><64><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƣ<EFBFBD>](#4-push-down-method<6F><64><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
* [5. Push Down Field<6C><64><EFBFBD>ֶ<EFBFBD><D6B6><EFBFBD><EFBFBD>ƣ<EFBFBD>](#5-push-down-field<6C>ֶ<EFBFBD><D6B6><EFBFBD><EFBFBD><EFBFBD>)
* [6. Extract Subclass<73><73><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>](#6-extract-subclass<73><73><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
* [7. Extract Superclass<73><73><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>](#7-extract-superclass<73><73><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
* [8. Extract Interface<63><65><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӿڣ<D3BF>](#8-extract-interface<63><65><EFBFBD><EFBFBD><EFBFBD>ӿ<EFBFBD>)
* [9. Collapse Hierarchy<68><79><EFBFBD>۵<EFBFBD><DBB5>̳<EFBFBD><CCB3><EFBFBD>ϵ<EFBFBD><CFB5>](#9-collapse-hierarchy<68>۵<EFBFBD><DBB5>̳<EFBFBD><CCB3><EFBFBD>ϵ)
* [10. Form Template Method<6F><64><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģ<EFBFBD><EFBFBD><E5BAAF><EFBFBD><EFBFBD>](#10-form-template-method<6F><64><EFBFBD><EFBFBD>ģ<EFBFBD><EFBFBD><E5BAAF>)
* [11. Replace Inheritance with Delegation <20><><EFBFBD><EFBFBD>ί<EFBFBD><CEAF>ȡ<EFBFBD><C8A1><EFBFBD>̳У<CCB3>](#11-replace-inheritance-with-delegation-<2D><>ί<EFBFBD><CEAF>ȡ<EFBFBD><C8A1><EFBFBD>̳<EFBFBD>)
* [12. Replace Delegation with Inheritance <20><><EFBFBD>Լ̳<D4BC>ȡ<EFBFBD><C8A1>ί<EFBFBD>У<EFBFBD>](#12-replace-delegation-with-inheritance-<2D>Լ̳<D4BC>ȡ<EFBFBD><C8A1>ί<EFBFBD><CEAF>)
2018-02-22 01:06:40 +08:00
<!-- GFM-TOC -->
2018-02-22 14:47:54 +08:00
# <20><>һ<EFBFBD><D2BB> <20><>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Լ<EFBFBD><EFBFBD><EFBFBD>ҪΪ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><EFBFBD><EFBFBD>޷<EFBFBD><EFBFBD>ܷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ش<EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD>ģ<EFBFBD><EFBFBD>Ǿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ع<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD>ع<EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>ȹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ÿɿ<EFBFBD><EFBFBD>IJ<EFBFBD><EFBFBD>Ի<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȫ<EFBFBD><EFBFBD><EFBFBD>ع<EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD>ع<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>΢С<EFBFBD>IJ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>޸ij<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>´<EFBFBD><EFBFBD>󣬺<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ױ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Է<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
**<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>**
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
ӰƬ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD>ó<EFBFBD><EFBFBD>򣬰<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ࣺMovie<EFBFBD><EFBFBD>Rental <20><> Customer<65><72>Rental <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>޵<EFBFBD> Movie <20>Լ<EFBFBD><D4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
![](https://github.com/CyC2018/InterviewNotes/blob/master/pics/a758c8b2-0ac7-438f-90c2-3923ffad6328.png)
2018-02-22 14:47:54 +08:00
<EFBFBD>ʼ<EFBFBD><EFBFBD>ʵ<EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>еļƷѴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Customer <20><><EFBFBD>У<EFBFBD><D0A3>ڱ仯<DAB1><E4BBAF><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD>ⲿ<EFBFBD>ִ<EFBFBD><D6B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>и<EFBFBD><D0B8>ġ<EFBFBD><C4A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>п<EFBFBD><D0BF>ܷ<EFBFBD><DCB7><EFBFBD><EFBFBD>ı<C4B1>У<EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļƷѷ<C6B7>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD>ı<C4B1><E4A3BB><EFBFBD><EFBFBD><EFBFBD>µĵ<C2B5>Ӱ<EFBFBD><D3B0><EFBFBD>𡣿<EFBFBD><F0A1A3BF>ǵ<EFBFBD><C7B5>ƷѴ<C6B7><D1B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܴ<EFBFBD><DCB4><EFBFBD><EFBFBD>ڶദ<DAB6><E0B4A6>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>мƷѴ<C6B7><D1B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>޸ġ<DEB8>
2018-02-22 01:06:40 +08:00
![](https://github.com/CyC2018/InterviewNotes/blob/master/pics/9e5e3cc6-3107-4051-b584-8ff077638fe6.png)
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ǽ̳<EFBFBD> Movie <20>Ķ<EFBFBD>̬<EFBFBD><CCAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB> Movie <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ᶯ̬<E1B6AF>ı<C4B1><E4A3AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD>
2018-02-22 01:06:40 +08:00
![](https://github.com/CyC2018/InterviewNotes/blob/master/pics/2a502516-5d34-4eef-8f39-916298a60035.png)
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD><EFBFBD> Price <20><><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD><EFBFBD>ϵķ<CFB5>ʽ<EFBFBD><CABD> Movie <20>м<EFBFBD><D0BC><EFBFBD> Price <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ÿ<EFBFBD><C3BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļƷѷ<C6B7>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD>װ<EFBFBD>ڲ<EFBFBD>ͬ<EFBFBD><CDAC> Price <20><><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD><D0A3><EFBFBD><EFBFBD><EFBFBD> Movie <20><><EFBFBD><EFBFBD>Ҳ<EFBFBD><D2B2><EFBFBD>Զ<EFBFBD>̬<EFBFBD>ı<EFBFBD><C4B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD>ʽ<EFBFBD><CABD><EFBFBD>Ժܺõ<DCBA><C3B5><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ı<C4B1><E4BBAF>
2018-02-22 01:06:40 +08:00
![](https://github.com/CyC2018/InterviewNotes/blob/master/pics/c02a83b8-a6b9-4d00-a509-6f0516beaf5e.png)
2018-02-22 14:47:54 +08:00
<EFBFBD>ع<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>ͼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
![](https://github.com/CyC2018/InterviewNotes/blob/master/pics/95f4559c-3d2a-4176-b365-4fbc46c76cf1.png)
![](https://github.com/CyC2018/InterviewNotes/blob/master/pics/293b9326-02fc-4ad8-8c79-b4a7b5ba60d3.png)
2018-02-22 14:47:54 +08:00
# <20>ڶ<EFBFBD><DAB6><EFBFBD> <20>ع<EFBFBD>ԭ<EFBFBD><D4AD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD>ع<EFBFBD><EFBFBD>Ƕ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD><EFBFBD>ı<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɹ۲<EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD>£<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>޸ijɱ<EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD>ع<EFBFBD><EFBFBD>ĺô<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ľ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƣ<EFBFBD>ʹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҵ<EFBFBD> bug<75><67><EFBFBD><EFBFBD><EFBFBD>߱<EFBFBD><DFB1><EFBFBD><EFBFBD>ٶȡ<D9B6>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD>η<EFBFBD><EFBFBD>򣺵<EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ij<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱֻ<EFBFBD><EFBFBD>ȥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƶ<EFBFBD><EFBFBD>£<EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD><EFBFBD>ع<EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD>Ӳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ع<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD>еĺܶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߼<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><EFBFBD>ʵ<EFBFBD>֣<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>װ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߼<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ع<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD>ò<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӳ<EFBFBD><EFBFBD>Լ<EFBFBD><EFBFBD>ڲ<EFBFBD><EFBFBD><EFBFBD>Ҫʱ<EFBFBD>Ƴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӳ㡣
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD>޸Ľӿڣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɽӿڣ<EFBFBD><EFBFBD>þɽӿ<EFBFBD>ȥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>½ӿڣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><EFBFBD> Java <20><EFBFBD><E1B9A9> @deprecation <20><><EFBFBD>ɽӿڱ<D3BF><DAB1><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD>á<EFBFBD><C3A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>ӿڣ<D3BF><DAA3><EFBFBD><EFBFBD>Ҳ<EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><E7B7A2><EFBFBD>ӿڡ<D3BF>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڻ<EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ع<EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>еİ취<EFBFBD>ǣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>װ<EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȼ<EFBFBD><EFBFBD><EFBFBD>Ը<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ع<EFBFBD><EFBFBD>ľ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>޷<EFBFBD>Ԥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƣ<EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>кܶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǽ<EFBFBD>ȥ<EFBFBD><EFBFBD><EFBFBD>ع<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Լ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƣ<EFBFBD><EFBFBD>ع<EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD>򵥵<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ͻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>޸ĸģ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ķ<EFBFBD>ʽȥӦ<EFBFBD>Ա仯<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ơ<EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ع<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܻᵼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܼ<EFBFBD><EFBFBD>͡<EFBFBD><EFBFBD>ڱ<EFBFBD>д<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ö<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><EFBFBD>ֻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ż<EFBFBD><EFBFBD>׶<EFBFBD><EFBFBD>ٿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>⡣Ӧ<EFBFBD><EFBFBD>ֻ<EFBFBD><EFBFBD>ע<EFBFBD>ؼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܣ<EFBFBD><EFBFBD><EFBFBD>Ϊֻ<EFBFBD><EFBFBD>һС<EFBFBD><EFBFBD><EFBFBD>ֵĴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǹؼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
# <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ļ<EFBFBD>ζ<EFBFBD><CEB6>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
## 1. Duplicated Code<64><65><EFBFBD>ظ<EFBFBD><D8B8><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
ͬһ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Extract Method <20><>ȡ<EFBFBD><C8A1><EFBFBD>ظ<EFBFBD><D8B8><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD>ֵܵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬ<EFBFBD>ı<EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><EFBFBD> Extract Method<6F><64>Ȼ<EFBFBD><C8BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD>ĺ<EFBFBD><C4BA><EFBFBD> Pull Up Method <20><><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֻ<EFBFBD>Dz<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> Extract Method <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʋ<EFBFBD><C6B2>ֺͲ<D6BA><CDB2>첿<EFBFBD>֣<EFBFBD>Ȼ<EFBFBD><C8BB>ʹ<EFBFBD><CAB9> Form Template Method <20><><EFBFBD><EFBFBD>ģ<EFBFBD><EFBFBD><E5B7BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ<C4A3><CABD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ظ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><EFBFBD> Extract Class <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ظ<EFBFBD><D8B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
## 2. Long Method<6F><64><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD>Ӳ<EFBFBD><EFBFBD>ļ<EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD>ֽ⺯<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԭ<EFBFBD>򣺵<EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD>ע<EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>һ<EFBFBD>δ<EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD>ⲿ<EFBFBD>ִ<EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĺ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
Extract Method <20><><EFBFBD>Ѻܶ<D1BA><DCB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Replace Temp with Query <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Introduce Parameter Object <20><> Preserve Whole Object <20><><EFBFBD>Խ<EFBFBD><D4BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IJ<EFBFBD><C4B2><EFBFBD><EFBFBD>б<EFBFBD><D0B1>ø<EFBFBD><C3B8><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѭ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҳ<EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD>µĺ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
## 3. Large Class<73><73><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˹<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫʹ<EFBFBD><EFBFBD> Extract Class <20><> Extract Subclass<73><73>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD>ȷ<EFBFBD><EFBFBD><EFBFBD>ͻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǣ<EFBFBD>Ȼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Extract Interface Ϊÿһ<C3BF><D2BB>ʹ<EFBFBD>÷<EFBFBD>ʽ<EFBFBD><CABD>ȡ<EFBFBD><C8A1>һ<EFBFBD><D2BB><EFBFBD>ӿڡ<D3BF>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
## 4. Long Parameter List<73><74><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IJ<EFBFBD><C4B2><EFBFBD><EFBFBD>У<EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
## 5. Divergent Change<67><65><EFBFBD><EFBFBD>ɢʽ<C9A2><EFBFBD><E4BBAF>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֱ仯<EFBFBD><EFBFBD>Ӱ<EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ij<EFBFBD><EFBFBD>ԭ<EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD><EFBFBD>ʹ<EFBFBD><EFBFBD> Extract Class <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
## 6. Shotgun Surgery<72><79>ɢ<EFBFBD><C9A2>ʽ<EFBFBD>޸ģ<DEB8>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>޸ģ<EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
ʹ<EFBFBD><EFBFBD> Move Method <20><> Move Field <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>޸ĵش<C4B5><D8B4><EFBFBD><EFBFBD>ŵ<EFBFBD>ͬһ<CDAC><D2BB><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
## 7. Feature Envy<76><79><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ij<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȥ<EFBFBD><EFBFBD><EFBFBD>ڶ<EFBFBD><EFBFBD>Լ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȥ<EFBFBD><EFBFBD>ͨ<EFBFBD><EFBFBD><EFBFBD>ǹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݡ<EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
ʹ<EFBFBD><EFBFBD> Move Method <20><><EFBFBD><EFBFBD><EFBFBD>Ƶ<EFBFBD><C6B5><EFBFBD>ȥ<EFBFBD>ĵط<C4B5><D8B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD><E0B6BC> Feature Envy<76><79><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Extract Method <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
## 8. Data Clumps<70><73><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ţ<EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD>Щ<EFBFBD><EFBFBD><EFBFBD>ݾ<EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֣<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬ<EFBFBD><EFBFBD><EFBFBD>ֶΡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬ<EFBFBD>IJ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><EFBFBD> Extract Class <20><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
## 9. Primitive Obsession<6F><6E><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƫִ<C6AB><D6B4>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
ʹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD>û<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>͸<EFBFBD><EFBFBD>ã<EFBFBD>ʹ<EFBFBD><EFBFBD> Replace Data Value with Object <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD>滻Ϊ<E6BBBB><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
## 10. Switch Statements<74><73>switch <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
## 11. Parallel Inheritance Hierarchies<65><73>ƽ<EFBFBD>м̳<D0BC><CCB3><EFBFBD>ϵ<EFBFBD><CFB5>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
ÿ<EFBFBD><EFBFBD>Ϊij<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҲΪ<EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD>ֽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һЩ<EFBFBD>ظ<EFBFBD><EFBFBD>ԣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ظ<EFBFBD><EFBFBD>Ե<EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԣ<EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD>̳<EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD><EFBFBD>ʵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD>̳<EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD><EFBFBD>ʵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
## 12. Lazy Class<73><73><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĺ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
## 13. Speculative Generality<74><79><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD≯δ<CCB8><CEB4><EFBFBD>ԣ<EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD>Щ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>δ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵͳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ά<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ԥ<EFBFBD><EFBFBD>δ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĸı<EFBFBD><EFBFBD>ܿ<EFBFBD><EFBFBD>ܺ<EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>DZ<EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD>Ͳ<EFBFBD>Ҫ<EFBFBD><EFBFBD>ô<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
## 14. Temporary Field<6C><64><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ի<EFBFBD><D4BB><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>ֶΣ<D6B6>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
ij<EFBFBD><EFBFBD><EFBFBD>ֶν<EFBFBD>Ϊij<EFBFBD><EFBFBD><EFBFBD>ض<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊͨ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶΡ<EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶκ<EFBFBD><EFBFBD>ض<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><EFBFBD> Extract Class <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
## 15. Message Chains<6E><73><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD><CFB5><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȼ<EFBFBD><EFBFBD>...<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD>ζ<EFBFBD>ſͻ<C5BF><CDBB><EFBFBD><EFBFBD><EFBFBD><EBBDAB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĺ<EFBFBD>ϵ<EFBFBD><CFB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϡ<EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD>ú<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ú<EFBFBD><EFBFBD><EFBFBD>ί<EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
## 16. Middle Man<61><6E><EFBFBD>м<EFBFBD><D0BC>ˣ<EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD>м<EFBFBD><EFBFBD>˸<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ί<EFBFBD>и<EFBFBD><EFBFBD><EFBFBD><EFBFBD>IJ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>й<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĺ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ί<EFBFBD>и<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ǿ<EFBFBD><EFBFBD>ǹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ί<EFBFBD>У<EFBFBD>Ӧ<EFBFBD><EFBFBD> Remove Middle Man<61><6E>ֱ<EFBFBD><D6B1><EFBFBD><EFBFBD><EBB8BA><EFBFBD>Ķ<EFBFBD><C4B6><EFBFBD><EFBFBD>򽻵<EFBFBD><F2BDBBB5><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
## 17. Inappropriate Intimacy<63><79><EFBFBD><EFBFBD><EFBFBD>ǹ<EFBFBD>ϵ<EFBFBD><CFB5>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̫<EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>ȥ̽<EFBFBD>ֱ˴˵<EFBFBD> private <20>ɷ֡<C9B7>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
## 18. Alernative Classes with Different Interfaces<65><73><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
## 19. Incomplete Library Class<73><73><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߲<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һЩ<EFBFBD>޸<EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֻ<EFBFBD><EFBFBD><EFBFBD>޸<EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><EFBFBD> Introduce Foreign Method<6F><64><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>Ѷ<EFBFBD><D1B6><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>ʹ<EFBFBD><CAB9> Introduce Local Extension<6F><6E>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
## 20. Data Class<73><73><EFBFBD><EFBFBD><EFBFBD>ɵ<EFBFBD><C9B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD>ֻӵ<EFBFBD><EFBFBD>һЩ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶΡ<EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD>ҳ<EFBFBD><EFBFBD>ֶ<EFBFBD>ʹ<EFBFBD>õĵط<EFBFBD><EFBFBD><EFBFBD>Ȼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD>IJ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƶ<EFBFBD> Data Class <20>С<EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
## 21. Refused Bequest<73><74><EFBFBD><EFBFBD><EFBFBD>ܾ<EFBFBD><DCBE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̳г<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>к<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֻ<EFBFBD><EFBFBD>Ҫһ<EFBFBD><EFBFBD><EFBFBD>֡<EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>½<EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>ĺ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><EFBFBD> Push Down Method <20><> Push Down Field <20><><EFBFBD>Ƹ<EFBFBD><C6B8>Ǹ<EFBFBD><C7B8>ֵܡ<D6B5>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
## 22. Comments<74><73><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD>ͣ<EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
ʹ<EFBFBD><EFBFBD> Extract Method <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫע<D2AA>͵IJ<CDB5><C4B2>֣<EFBFBD>Ȼ<EFBFBD><C8BB><EFBFBD>ú<EFBFBD><C3BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͺ<EFBFBD><CDBA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
# <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵ
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
Java <20><><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9> Junit <20><><EFBFBD>е<EFBFBD>Ԫ<EFBFBD><D4AA><EFBFBD>ԡ<EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD>Ԫ<EFBFBD><EFBFBD><EFBFBD>ԵĶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ķ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܲ<EFBFBD><EFBFBD>Կͻ<EFBFBD><EFBFBD>ĽǶȱ<EFBFBD>֤<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
Ӧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>в<EFBFBD><EFBFBD>Կ<EFBFBD><EFBFBD>ܳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ı߽<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
# <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ع<EFBFBD><D8B9>б<EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
С<EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԡ<EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
# <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֯<EFBFBD><D6AF><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
## 1. Extract Method<6F><64><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>δ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ž<EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ú<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƽ<EFBFBD><EFBFBD>͸ú<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;<EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
## 2. Inline Method<6F><64><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>׶<EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD>ں<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>壬Ȼ<EFBFBD><EFBFBD><EFBFBD>Ƴ<EFBFBD><EFBFBD>ú<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
## 3. Inline Temp<6D><70><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֻ<EFBFBD><EFBFBD><EFBFBD>򵥱<EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD>ֵһ<EFBFBD>Σ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ع<EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>жԸñ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>滻Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD>Ǹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
```java
double basePrice = anOrder.basePrice();
return basePrice > 1000;
```
```java
return anOrder.basePrice() > 1000;
```
2018-02-22 14:47:54 +08:00
## 4. Replace Temp with Query<72><79><EFBFBD>Բ<EFBFBD>ѯȡ<D1AF><C8A1><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ijһ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD><EFBFBD>滻Ϊ<EFBFBD><EFBFBD><EFBFBD>º<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD><EFBFBD>á<EFBFBD>Replace Temp with Query <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Extract Method ֮ǰ<D6AE>ز<EFBFBD><D8B2><EFBFBD><EFBFBD>ٵ<EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E8A3AC>Ϊ<EFBFBD>ֲ<EFBFBD><D6B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
```java
double basePrice = quantity * itemPrice;
if(basePrice > 1000)
return basePrice * 0.95;
else
return basePrice * 0.98;
```
```java
if(basePrice() > 1000)
return basePrice() * 0.95;
else
return basePrice() * 0.98;
// ...
double basePrice(){
return quantity * itemPrice;
}
```
2018-02-22 14:47:54 +08:00
## 5. Introduce Explaining Variable<6C><65><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͱ<EFBFBD><CDB1><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӱ<EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD>֣<EFBFBD><EFBFBD>Ľ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ž<EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ˱<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͱ<EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD>;<EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
```java
if((platform.toUpperCase().indexOf("MAC") > -1) &&
(browser.toUpperCase().indexOf("IE") > -1) &&
wasInitialized() && resize > 0) {
// do something
}
```
```java
final boolean isMacOS = platform.toUpperCase().indexOf("MAC") > -1;
final boolean isIEBrower = browser.toUpperCase().indexOf("IE") > -1;
final boolean wasResized = resize > 0;
if(isMacOS && isIEBrower && wasInitialized() && wasResized) {
// do something
}
```
2018-02-22 14:47:54 +08:00
## 6. Split Temporary Variable<6C><65><EFBFBD>ֽ<EFBFBD><D6BD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
ij<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>Σ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȳ<EFBFBD><EFBFBD><EFBFBD>ѭ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ռ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ÿ<EFBFBD>θ<EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ÿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֻ<EFBFBD>е<EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ρ<EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
## 7. Remove Assigments to Parameters<72><73><EFBFBD>Ƴ<EFBFBD><C6B3>Բ<EFBFBD><D4B2><EFBFBD><EFBFBD>ĸ<EFBFBD>ֵ<EFBFBD><D6B5>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD>Ըò<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĸ<EFBFBD>ֵ<EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
```java
int discount (int inputVal, int quentity, int yearToDate){
if (inputVal > 50) inputVal -= 2;
```
```java
int discount (int inputVal, int quentity, int yearToDate){
int result = inputVal;
if (inputVal > 50) result -= 2;
```
2018-02-22 14:47:54 +08:00
## 8. Replace Method with Method Object<63><74><EFBFBD>Ժ<EFBFBD><D4BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͺ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Extract Method ʱ<><CAB1><EFBFBD><EFBFBD><EFBFBD>ڰ<EFBFBD><DAB0><EFBFBD><EFBFBD>˾ֲ<CBBE><D6B2><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD>ú<EFBFBD><C3BA>ѽ<EFBFBD><D1BD>иò<D0B8><C3B2><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ž<EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD>ֲ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͳ<EFBFBD><EFBFBD>˶<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><EFBFBD>ֶΡ<EFBFBD>Ȼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬһ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>н<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͺ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֽ<EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD>ͺ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
## 9. Subsititute Algorithn<68><6E><EFBFBD><EFBFBD><EFBFBD><E3B7A8>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
# <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ڶ<EFBFBD><DAB6><EFBFBD>֮<EFBFBD><D6AE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
## 1. Move Method<6F><64><EFBFBD><EFBFBD><EFBFBD>ƺ<EFBFBD><C6BA><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD>е<EFBFBD>ij<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>и<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ú<EFBFBD><EFBFBD>߻<EFBFBD><EFBFBD>߱<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ߵ<EFBFBD><EFBFBD>á<EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƶ<EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
## 2. Move Field<6C><64><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶΣ<D6B6>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD>е<EFBFBD>ij<EFBFBD><EFBFBD><EFBFBD>ֶα<EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡֵ<EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD><EFBFBD>Ѹ<EFBFBD><EFBFBD>ֶ<EFBFBD><EFBFBD>Ƶ<EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
## 3. Extract Class<73><73><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
ij<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¡<EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
Ӧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD><EFBFBD>ֶκͺ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
## 4. Inline Class<73><73><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD> Extract Class <20><EFBFBD><E0B7B4>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
## 5. Hide Delegate<74><65><EFBFBD><EFBFBD><EFBFBD>ء<EFBFBD>ί<EFBFBD>й<EFBFBD>ϵ<EFBFBD><CFB5><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĺ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ί<EFBFBD>й<EFBFBD>ϵ<EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
```java
class Person{
Department department;
public Department getDepartment(){
return department;
}
}
class Department{
private Person manager;
public Person getManager(){
return manager;
}
}
```
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͻ<EFBFBD>ϣ<EFBFBD><EFBFBD>֪<EFBFBD><EFBFBD>ij<EFBFBD>˵ľ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˭<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Department <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͶԿͻ<D4BF><CDBB><EFBFBD><EFBFBD><C2B6> Department <20>Ĺ<EFBFBD><C4B9><EFBFBD>ԭ<EFBFBD><D4AD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
```java
Person manager = john.getDepartment().getManager();
```
2018-02-22 14:47:54 +08:00
ͨ<EFBFBD><EFBFBD>Ϊ Peron <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ί<EFBFBD>й<EFBFBD>ϵ<EFBFBD><CFB5>
2018-02-22 01:06:40 +08:00
```java
public Person getManager(){
return department.getManager();
}
```
2018-02-22 14:47:54 +08:00
## 6. Remove Middle Man<61><6E><EFBFBD>Ƴ<EFBFBD><C6B3>м<EFBFBD><D0BC>ˣ<EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD> Hide Delegate <20><EFBFBD><E0B7B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>Ƴ<EFBFBD>ί<EFBFBD>к<EFBFBD><D0BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ÿͻ<C3BF>ֱ<EFBFBD>ӵ<EFBFBD><D3B5><EFBFBD>ί<EFBFBD><CEAF><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
Hide Delegate <20>кܴ<D0BA><DCB4>ô<EFBFBD><C3B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD>ǣ<EFBFBD>ÿ<EFBFBD><C3BF><EFBFBD>ͻ<EFBFBD>Ҫʹ<D2AA><CAB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>ͱ<EFBFBD><CDB1><EFBFBD><EFBFBD>ڷ<EFBFBD><DAB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>򵥵<EFBFBD>ί<EFBFBD>к<EFBFBD><D0BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ί<EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD>Խ<EFBFBD><D4BD>Խ<EFBFBD><EFBFBD><E0A3AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȫ<EFBFBD><C8AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD>м<EFBFBD><D0BC>ˡ<EFBFBD><CBA1><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
## 7. Introduce Foreign Method<6F><64><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӻ<EFBFBD><D3BA><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD>ҪΪ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>޷<EFBFBD><EFBFBD>޸<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڿͻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>н<EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ե<EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ÿͻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϸ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
## 8. Introduce Local Extension<6F><6E><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EBB1BE><EFBFBD><EFBFBD>չ<EFBFBD><D5B9>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD> Introduce Foreign Method Ŀ<><C4BF>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Introduce Local Extension ͨ<><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD><C2B5><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD>֡<EFBFBD><D6A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߰<EFBFBD>װ<EFBFBD><EFBFBD><E0A3AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8><EFBFBD>̳<EFBFBD>ʵ<EFBFBD>֣<EFBFBD><D6A3><EFBFBD>װ<EFBFBD><D7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD>֡<EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
# <20>ڰ<EFBFBD><DAB0><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֯<EFBFBD><D6AF><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
## 1. Self Encapsulate Field<6C><64><EFBFBD>Է<EFBFBD>װ<EFBFBD>ֶΣ<D6B6>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
Ϊ<EFBFBD>ֶν<EFBFBD><EFBFBD><EFBFBD>ȡֵ/<2F><>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Щ<EFBFBD><D0A9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶΡ<D6B6>ֻ<EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʳ<EFBFBD><CAB3><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>ֶΣ<D6B6><CEA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>н<EFBFBD><D0BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶη<D6B6><CEB7>ʸ<EFBFBD>Ϊһ<CEAA><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD>ӷ<EFBFBD><D3B7><EFBFBD><EFBFBD>ֶεķ<CEB5>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˡ<EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
## 2. Replace Data Value with Object<63><74><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD>ڿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ü򵥵<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD>򵥵<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ſ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ľ<EFBFBD><EFBFBD>У<EFBFBD>һЩ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һЩ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD>ѵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ绰<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD>š<EFBFBD>֮<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
## 3. Change Value to Reference<63><65><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD>ij<EFBFBD><C4B3><EFBFBD><EFBFBD>ö<EFBFBD><C3B6><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD>˴<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȵ<EFBFBD>ʵ<EFBFBD><EFBFBD><EFBFBD>滻Ϊͬһ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ψһ<EFBFBD><EFBFBD><EFBFBD>󣬹<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD>Ѿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD>Ȳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD>Ѿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڸö<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD><EFBFBD>򷵻<EFBFBD><EFBFBD>б<EFBFBD><EFBFBD>е<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>󣻷<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>½<EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD><EFBFBD>б<EFBFBD><EFBFBD>У<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ظö<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
## 4. Change Reference to value<75><65><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ö<EFBFBD><C3B6><EFBFBD><EFBFBD><EFBFBD>Ϊֵ<CEAA><D6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD> Change Value to Reference <20><EFBFBD><E0B7B4>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD>и<EFBFBD><D0B8>dz<EFBFBD><C7B3><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>ԣ<EFBFBD><D4A3><EFBFBD><EFBFBD>Dz<EFBFBD><C7B2>ɱ<EFBFBD><C9B1>ģ<EFBFBD><C4A3><EFBFBD><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>Ҫ<EFBFBD>ı<EFBFBD><C4B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>󣬱<EFBFBD><F3A3ACB1><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>µĶ<C2B5><C4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɶ<EFBFBD><C9B6>󣬶<EFBFBD><F3A3ACB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>޸ľɶ<C4BE><C9B6><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD>ҪΪֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD><EFBFBD> equals() <20><> hashCode() <20><><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
## 5. Replace Array with Object<63><74><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD>Ԫ<EFBFBD>ظ<EFBFBD><EFBFBD>Դ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬ<EFBFBD>Ķ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD>Զ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD>ÿ<EFBFBD><EFBFBD>Ԫ<EFBFBD>أ<EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
## 6. Duplicate Observed Data<74><61><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݡ<EFBFBD><DDA1><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
һЩ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> GUI <20>ؼ<EFBFBD><D8BC>У<EFBFBD><D0A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Щ<EFBFBD><D0A9><EFBFBD>ݡ<EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݸ<EFBFBD>ֵ<EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD> Oberver ģʽ<C4A3><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> GUI <20><><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><DAB5>ظ<EFBFBD><D8B8><EFBFBD><EFBFBD>ݡ<EFBFBD>
2018-02-22 01:06:40 +08:00
![](https://github.com/CyC2018/InterviewNotes/blob/master/pics/e024bd7e-fb4e-4239-9451-9a6227f50b00.jpg)
2018-02-22 14:47:54 +08:00
## 7. Change Unidirectional Association to Bidirectional<61><6C><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ˫<CEAA><CBAB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>Է<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><EFBFBD>˫<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> Order <20>Ϳͻ<CDBF> Customer<65><72>Order <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Customer<65><72>Customer Ҳ<><D2B2>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD> Order <20><><EFBFBD><EFBFBD><E9BFB4><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
```java
class Order{
private Customer customer;
public void setCustomer(Customer customer){
if(this.customer != null)
this.customer.removeOrder(this);
this.customer = customer;
this.customer.add(this);
}
}
```
```java
class Curstomer{
private Set<Order> orders = new HashSet<>();
public void removeOrder(Order order){
orders.remove(order);
}
public void addOrder(Order order){
orders.add(order);
}
}
```
2018-02-22 14:47:54 +08:00
ע<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Curstomer <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƹ<EFBFBD><C6B9><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD><CFB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԭ<EFBFBD><D4AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĸ<EFBFBD><C4B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƹ<EFBFBD><C6B9><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD><CFB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ij<EFBFBD><C4B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IJ<EFBFBD><C4B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ô<EFBFBD>ɺ<EFBFBD><C9BA>߸<EFBFBD><DFB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƹ<EFBFBD><C6B9><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD><CFB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>Զ<EFBFBD><D4B6><EFBFBD>ϵ<EFBFBD><CFB5><EFBFBD><EFBFBD><EFBFBD>ɵ<EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƹ<EFBFBD><C6B9><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD><CFB5>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
## 8. Change Bidirectional Association to Unidirectional<61><6C><EFBFBD><EFBFBD>˫<EFBFBD><CBAB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD> Change Unidirectional Association to Bidirectiona Ϊ<><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
˫<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ά<EFBFBD><EFBFBD><EFBFBD>ɱ<EFBFBD><EFBFBD>ߣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˫<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɡ<EFBFBD><EFBFBD><EFBFBD>ʬ<EFBFBD><EFBFBD><EFBFBD>󡱣<EFBFBD>ij<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ѿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˣ<EFBFBD>ȴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵͳ<EFBFBD>У<EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD>û<EFBFBD><EFBFBD>ȫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
## 9. Replace Magic Number with Symbolic Constant<6E><74><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E6B3A3>ȡ<EFBFBD><C8A1>ħ<EFBFBD><C4A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
## 10. Encapsulate Field<6C><64><EFBFBD><EFBFBD>װ<EFBFBD>ֶΣ<D6B6>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
public <20>ֶ<EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD>Ϊ private<74><65><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E1B9A9>Ӧ<EFBFBD>ķ<EFBFBD><C4B7>ʺ<EFBFBD><CABA><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
## 11. Encapsulate Collection<6F><6E><EFBFBD><EFBFBD>װ<EFBFBD><D7B0><EFBFBD>ϣ<EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ؼ<EFBFBD><EFBFBD>ϵ<EFBFBD>һ<EFBFBD><EFBFBD>ֻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>/<2F>Ƴ<EFBFBD><C6B3><EFBFBD><EFBFBD><EFBFBD>Ԫ<EFBFBD>صĺ<D8B5><C4BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ؼ<EFBFBD><D8BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>޸ļ<DEB8><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݶ<EFBFBD><DDB6><EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD><D3B5><EFBFBD><EFBFBD>ȴһ<C8B4><D2BB><EFBFBD><EFBFBD>֪<EFBFBD><D6AA>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
## 12. Replace Record with Data Class<73><73><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>¼<EFBFBD><C2BC>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
## 13. Replace Type Code with Class<73><73><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> switch <20><><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD><D0A3><EFBFBD>Ҫʹ<D2AA><CAB9> Replace Conditional with Polymorphism ȥ<><C8A5> switch<63><68><EFBFBD><EFBFBD><EFBFBD>ȱ<EFBFBD><C8B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Replace Type Code with Subcalss <20><> Replace Type Code with State/Strategy ȥ<><C8A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
![](https://github.com/CyC2018/InterviewNotes/blob/master/pics/27c2e0b3-8f95-453d-bedc-6398a8566ce9.jpg)
2018-02-22 14:47:54 +08:00
## 14. Replace Type Code with Subcalsses<65><73><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
![](https://github.com/CyC2018/InterviewNotes/blob/master/pics/c41d3977-e0e7-4ee4-93e1-d84f1ae3e20e.jpg)
2018-02-22 14:47:54 +08:00
## 15. Replace Type Code with State/Strategy <20><><EFBFBD><EFBFBD> State/Strategy ȡ<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD>ɱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD> Replace Type Code with Subcalsses <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Replace Type Code with State/Strategy <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƕ<EFBFBD>̬<EFBFBD>ɱ<EFBFBD><C9B1>ģ<EFBFBD>ǰ<EFBFBD><C7B0>ͨ<EFBFBD><CDA8><EFBFBD>̳еķ<D0B5>ʽ<EFBFBD><CABD>ʵ<EFBFBD>֣<EFBFBD><D6A3><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD><EFBFBD>ϵķ<CFB5>ʽ<EFBFBD><CABD>ʵ<EFBFBD>֡<EFBFBD><D6A1><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɱ䣬<C9B1><E4A3AC><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8><EFBFBD>̳еķ<D0B5>ʽ<EFBFBD><CABD>һ<EFBFBD><D2BB>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ı<C4B1><E4A3AC>ô<EFBFBD><C3B4>Ҫ<EFBFBD>ı<EFBFBD><C4B1><EFBFBD><EFBFBD>µĶ<C2B5><C4B6><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD>ɶ<EFBFBD><C9B6>󣬶<EFBFBD><F3A3ACB6>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ըı<D4B8><C4B1>µĶ<C2B5><C4B6>󡣵<EFBFBD><F3A1A3B5><EFBFBD>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD><EFBFBD>ϵķ<CFB5>ʽ<EFBFBD><CABD><EFBFBD>ı<EFBFBD><C4B1><EFBFBD><EFBFBD>õ<EFBFBD>״̬<D7B4><CCAC><EFBFBD>Ǻ<EFBFBD><C7BA><EFBFBD><EFBFBD>׵ġ<D7B5>
2018-02-22 01:06:40 +08:00
![](https://github.com/CyC2018/InterviewNotes/blob/master/pics/81fd1d6f-a3b2-4160-9a0a-1f7cb50ba440.jpg)
2018-02-22 14:47:54 +08:00
## 16. Replace Subclass with Fields<64><73><EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ψһ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֻ<EFBFBD>ڡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>س<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݡ<EFBFBD><EFBFBD>ĺ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϡ<EFBFBD>
2018-02-22 01:06:40 +08:00
![](https://github.com/CyC2018/InterviewNotes/blob/master/pics/f2e0cee9-ecdc-4a96-853f-d9f6a1ad6ad1.jpg)
2018-02-22 14:47:54 +08:00
# <20>ھ<EFBFBD><DABE><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
## 1. Decompose Conditional<61><6C><EFBFBD>ֽ<EFBFBD><D6BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><CABD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ<EFBFBD> if<69><66>then<65><6E>else <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>зֱ<D0B7><D6B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
```java
if(data.befor(SUMMER_START) || data.after(SUMMER_END))
charge = quantity * winterRate + winterServiceCharge;
else charge = quantity * summerRate;
```
```java
if(notSummer(date))
charge = winterCharge(quantity);
else charge = summerCharge(quantity);
```
2018-02-22 14:47:54 +08:00
## 2. Consolidate Conditional Expression<6F><6E><EFBFBD>ϲ<EFBFBD><CFB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><CABD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD>һϵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD><EFBFBD><EFBFBD>ͬ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Щ<EFBFBD><EFBFBD><EFBFBD>Ժϲ<EFBFBD>Ϊһ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊһ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
```java
double disabilityAmount(){
if (seniority < 2) return 0;
if (monthsDisabled > 12 ) return 0;
if (isPartTime) return 0;
// ...
}
```
```java
double disabilityAmount(){
if (isNotEligibleForDisability()) return 0;
// ...
}
```
2018-02-22 14:47:54 +08:00
## 3. Consolidate Duplicate Conditional Fragments <20><><EFBFBD>ϲ<EFBFBD><CFB2>ظ<EFBFBD><D8B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƭ<EFBFBD>Σ<EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD>ÿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>֧<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬ<EFBFBD><EFBFBD>һ<EFBFBD>δ<EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ظ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ֮<EFBFBD>
2018-02-22 01:06:40 +08:00
```java
if (isSpecialDeal()){
total = price * 0.95;
send();
} else {
total = price * 0.98;
send();
}
```
```java
if (isSpecialDeal()) {
total = price * 0.95;
} else {
total = price * 0.98;
}
send();
```
2018-02-22 14:47:54 +08:00
## 4. Remove Control Flag<61><67><EFBFBD>Ƴ<EFBFBD><C6B3><EFBFBD><EFBFBD>Ʊ<EFBFBD><C6B1>ǣ<EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD>һϵ<EFBFBD>в<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD>У<EFBFBD>ij<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʊ<EFBFBD><EFBFBD>ǡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>á<EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD> break<61><6B> <20><><EFBFBD><EFBFBD> return <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD>Ʊ<EFBFBD><C6B1>ǡ<EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
## 5. Replace Nested Conditional with Guard Clauses <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1>Ƕ<EFBFBD><C7B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><CABD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ij<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD>õ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڸ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD>̴Ӻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>з<EFBFBD><EFBFBD>أ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>guard clauses<65><73><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽͨ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD>ǣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>з<EFBFBD>֧<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD>ڶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD><EFBFBD>ǣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD>Ĵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֻ<EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Dz<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
```java
double getPayAmount() {
double result;
if (isDead) result = deadAmount();
else {
if (isSeparated) result = separatedAmount();
else {
if (isRetired) result = retiredAmount();
else result = normalPayAmount();
};
}
return result;
};
```
```java
double getPayAmount() {
if (isDead) return deadAmount();
if (isSeparated) return separatedAmount();
if (isRetired) return retiredAmount();
return normalPayAmount();
};
```
2018-02-22 14:47:54 +08:00
## 6. Replace Conditional with Polymorphism <20><><EFBFBD>Զ<EFBFBD>̬ȡ<CCAC><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><CABD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD>ÿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>֧<EFBFBD>Ž<EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵĸ<EFBFBD>д<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD>Ȼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԭʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD>ʹ<EFBFBD><EFBFBD> Replace Type Code with Subclass <20><> Replace Type Code with State/Strategy <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̳н<CCB3><D0BD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
```java
double getSpeed() {
switch (type) {
case EUROPEAN:
return getBaseSpeed();
case AFRICAN:
return getBaseSpeed()- getLoadFactor()* numberOfCoconuts;
case NORWEGIAN_BLUE:
return isNailed ? 0 : getBaseSpeed(voltage);
}
throw new RuntimeException("Should be unreachable");
}
```
![](https://github.com/CyC2018/InterviewNotes/blob/master/pics/1c8432c8-2552-457f-b117-1da36c697221.jpg)
2018-02-22 14:47:54 +08:00
## 7. Introduce Null Object<63><74><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Null<6C><6C><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD> null ֵ<>滻Ϊ null <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĺô<C4BA><C3B4><EFBFBD><EFBFBD>ڣ<EFBFBD><DAA3><EFBFBD><EFBFBD><EFBFBD>Ҫѯ<D2AA>ʶ<EFBFBD><CAB6><EFBFBD><EFBFBD>Ƿ<EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>ֱ<EFBFBD>ӵ<EFBFBD><D3B5>þ<EFBFBD><C3BE>С<EFBFBD>
2018-02-22 01:06:40 +08:00
```java
if (customer == null) plan = BillingPlan.basic();
else plan = customer.getPlan();
```
2018-02-22 14:47:54 +08:00
## 8. Introduce Assertion<6F><6E><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԣ<EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD>Զ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ij<EFBFBD>ּ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD><EFBFBD><EFBFBD>Ʒ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>в<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><EFBFBD>ԡ<EFBFBD>
2018-02-22 01:06:40 +08:00
```java
double getExpenseLimit() {
// should have either expense limit or a primary project
return (expenseLimit != NULL_EXPENSE) ? expenseLimit : primaryProject.getMemberExpenseLimit();
}
```
```java
double getExpenseLimit() {
Assert.isTrue (expenseLimit != NULL_EXPENSE || primaryProject != null);
return (expenseLimit != NULL_EXPENSE) ? expenseLimit : primaryProject.getMemberExpenseLimit();
}
```
2018-02-22 14:47:54 +08:00
# <20><>ʮ<EFBFBD><CAAE> <20>򻯺<EFBFBD><F2BBAFBA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
## 1. Rename Method<6F><64><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
ʹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܽ<EFBFBD><EFBFBD>ͺ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;<EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
## 2. Add Parameter<65><72><EFBFBD><EFBFBD><EFBFBD>Ӳ<EFBFBD><D3B2><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
ʹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫͨ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><EFBFBD><EFBFBD>ij<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
## 3. Remove Parameter<65><72><EFBFBD>Ƴ<EFBFBD><C6B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD> Add Parameter <20><EFBFBD><E0B7B4><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD><C3B5>õķ<C3B5>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ij<EFBFBD><C4B3><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
## 4. Separate Query from Modifier<65><72><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>޸ĺ<DEB8><C4BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
ij<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ض<EFBFBD><EFBFBD><EFBFBD>״ֵ̬<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>޸Ķ<EFBFBD><EFBFBD><EFBFBD>״̬<EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
Ӧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬ<EFBFBD>ĺ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѯ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>޸ġ<EFBFBD><EFBFBD>κ<EFBFBD><EFBFBD>з<EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD>ĺ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD><EFBFBD>п<EFBFBD><EFBFBD>õ<EFBFBD><EFBFBD>ĸ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>á<EFBFBD>
2018-02-22 01:06:40 +08:00
```java
getTotalOutstandingAndSetReadyForSummaries();
```
```java
getTotalOutstanding();
setReadyForSummaries();
```
2018-02-22 14:47:54 +08:00
## 5. Parameterize Method<6F><64><EFBFBD><EFBFBD><EEBAAF>Я<EFBFBD><D0AF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD>ɺ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƵĹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ں<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˲<EFBFBD>ͬ<EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Բ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Щ<EFBFBD><EFBFBD>ͬ<EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
```java
fivePercentRaise();
tenPercentRaise();
```
```java
raise(percentage);
```
2018-02-22 14:47:54 +08:00
## 6. Replace Parameter with Explicit Methods<64><73><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȷ<EFBFBD><C8B7><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȫȡ<EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD>ͬ<EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD>Ըò<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ÿһ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
```java
void setValue(String name, int value){
if (name.equals("height")){
height = value;
return;
}
if (name.equals("width")){
width = value;
return;
}
Assert.shouldNeverReachHere();
}
```
```java
void setHeight(int arg){
height = arg;
}
void setWidth(int arg){
width = arg;
}
```
2018-02-22 14:47:54 +08:00
## 7. Preserve Whole Object<63><74><EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD><D6B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD>ij<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊijһ<EFBFBD>κ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>IJ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
```java
int low = daysTempRange().getLow();
int high = daysTempRange().getHigh();
withinPlan = plan.withinRange(low,high);
```
```java
withinPlan = plan.withinRange(daysTempRange());
```
2018-02-22 14:47:54 +08:00
## 8. Replace Parameter with Methods<64><73><EFBFBD>Ժ<EFBFBD><D4BA><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ij<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ý<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݸ<EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܸò<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĺ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҳ<EFBFBD>ܹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰһ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD>ò<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD>ӵ<EFBFBD><EFBFBD><EFBFBD>ǰһ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
```java
int basePrice = _quantity * _itemPrice;
discountLevel = getDiscountLevel();
double finalPrice = discountedPrice (basePrice, discountLevel);
```
```java
int basePrice = _quantity * _itemPrice;
double finalPrice = discountedPrice (basePrice);
```
2018-02-22 14:47:54 +08:00
## 9. Introduce Parameter Object<63><74><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
ijЩ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ǻ<EFBFBD><EFBFBD><EFBFBD>Ȼ<EFBFBD><EFBFBD>ͬʱ<EFBFBD><EFBFBD><EFBFBD>֣<EFBFBD><EFBFBD><EFBFBD>Щ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Data Clumps<70><73>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Щ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
![](https://github.com/CyC2018/InterviewNotes/blob/master/pics/08738dd0-ae8e-404a-ba78-a6b1b7d225b3.jpg)
2018-02-22 14:47:54 +08:00
## 10. Remove Setting Method<6F><64><EFBFBD>Ƴ<EFBFBD><C6B3><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD>е<EFBFBD>ij<EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD>Ӧ<EFBFBD><EFBFBD><EFBFBD>ڶ<EFBFBD><EFBFBD>󴴽<EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD>Ȼ<EFBFBD><EFBFBD><EFBFBD>Ͳ<EFBFBD><EFBFBD>ٸı
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
ȥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶε<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD><EFBFBD><EFBFBD>Ϊ final<61><6C>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
## 11. Hide Method<6F><64><EFBFBD><EFBFBD><EFBFBD>غ<EFBFBD><D8BA><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD>б<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>κ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>޸<EFBFBD>Ϊ private<74><65>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
## 12. Replace Constructor with Factory Method <20><><EFBFBD>Թ<EFBFBD><D4B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><ECBAAF><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
ϣ<EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>򵥵Ľ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>滻Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
## 13. Encapsulate Downcast<73><74><EFBFBD><EFBFBD>װ<EFBFBD><D7B0><EFBFBD><EFBFBD>ת<EFBFBD>ͣ<EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
ij<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>صĶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>ɺ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD>ͣ<EFBFBD>downcast<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD>Ͷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD>
2018-02-22 01:06:40 +08:00
```java
Object lastReading(){
return readings.lastElement();
}
```
```java
Reading lastReading(){
return (Reading)readings.lastElement();
}
```
2018-02-22 14:47:54 +08:00
## 14. Replace Error Code with Exception <20><><EFBFBD><EFBFBD><EFBFBD>쳣ȡ<ECB3A3><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
ij<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD>ض<EFBFBD><EFBFBD>Ĵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD>ʾij<EFBFBD>ִ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֿ<EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
## 15. Replace Exception with Test<73><74><EFBFBD>Բ<EFBFBD><D4B2><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><ECB3A3>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߿<EFBFBD><EFBFBD><EFBFBD>Ԥ<EFBFBD>ȼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>׳<EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD>޸ĵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ߣ<EFBFBD>ʹ<EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><EFBFBD>ú<EFBFBD><EFBFBD><EFBFBD>֮ǰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
```java
double getValueForPeriod(int periodNumber) {
try {
return values[periodNumber];
} catch (ArrayIndexOutOfBoundsException e) {
return 0;
}
}
```
```java
double getValueForPeriod(int periodNumber) {
if (periodNumber >= values.length) return 0;
return values[periodNumber];
```
2018-02-22 14:47:54 +08:00
# <20><>ʮһ<CAAE><D2BB> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵ
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
## 1. Pull Up Field<6C><64><EFBFBD>ֶ<EFBFBD><D6B6><EFBFBD><EFBFBD>ƣ<EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬ<EFBFBD><EFBFBD><EFBFBD>ֶΡ<EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
## 2. Pull Up Method<6F><64><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƣ<EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD>Щ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڸ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>в<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȫ<EFBFBD><EFBFBD>ͬ<EFBFBD>Ľ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD>ú<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
## 3. Pull Up Constructor Body<64><79><EFBFBD><EFBFBD><EFBFBD><EFBFBD><ECBAAF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƣ<EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD>ڸ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD><EFBFBD>һЩ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǵı<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȫһ<EFBFBD>¡<EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD>ڳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>½<EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
```java
class Manager extends Employee...
public Manager(String name, String id, int grade) {
this.name = name;
this.id = id;
this.grade = grade;
}
```
```java
public Manager(String name, String id, int grade) {
super(name, id);
this.grade = grade;
}
```
2018-02-22 14:47:54 +08:00
## 4. Push Down Method<6F><64><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƣ<EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD>ij<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֻ<EFBFBD>벿<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>йء<EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD><EFBFBD><EFBFBD>Щ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȥ<EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
## 5. Push Down Field<6C><64><EFBFBD>ֶ<EFBFBD><D6B6><EFBFBD><EFBFBD>ƣ<EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD>ij<EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD>ֻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD><EFBFBD>Ƶ<EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Щ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȥ<EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
## 6. Extract Subclass<73><73><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD>е<EFBFBD>ijЩ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֻ<EFBFBD><EFBFBD>ijЩʵ<EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD>½<EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
## 7. Extract Superclass<73><73><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԡ<EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
## 8. Extract Interface<63><65><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӿڣ<D3BF>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD>ɿͻ<EFBFBD>ʹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӿ<EFBFBD><EFBFBD>е<EFBFBD>ͬһ<EFBFBD>Ӽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ľӿ<EFBFBD><EFBFBD>в<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬ<EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬ<EFBFBD><EFBFBD><EFBFBD>Ӽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӿ<EFBFBD><EFBFBD>С<EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
## 9. Collapse Hierarchy<68><79><EFBFBD>۵<EFBFBD><DBB5>̳<EFBFBD><CCB3><EFBFBD>ϵ<EFBFBD><CFB5>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֮<EFBFBD><EFBFBD><EFBFBD><EFBFBD>̫<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ǻ<EFBFBD>Ϊһ<EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
## 10. Form Template Method<6F><64><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģ<EFBFBD><EFBFBD><E5BAAF><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>һЩ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD>ijЩ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬ˳<EFBFBD><EFBFBD>ִ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƵIJ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϸ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬ<EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Щ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD><EFBFBD>Ž<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƕ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬ<EFBFBD><EFBFBD>ǩ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԭ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҳ<EFBFBD>ͱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬ<EFBFBD>ˡ<EFBFBD>Ȼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԭ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ࡣ(ģ<><EFBFBD><E5B7BD>ģʽ)
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
## 11. Replace Inheritance with Delegation <20><><EFBFBD><EFBFBD>ί<EFBFBD><CEAF>ȡ<EFBFBD><C8A1><EFBFBD>̳У<CCB3>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
ij<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֻʹ<EFBFBD>ó<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӿ<EFBFBD><EFBFBD>е<EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD>֣<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ǹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>̳ж<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݡ<EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>½<EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ķ<EFBFBD>ί<EFBFBD>г<EFBFBD><EFBFBD>࣬Ȼ<EFBFBD><EFBFBD>ȥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֮<EFBFBD><EFBFBD><EFBFBD>ļ̳й<EFBFBD>ϵ<EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
## 12. Replace Delegation with Inheritance <20><><EFBFBD>Լ̳<D4BC>ȡ<EFBFBD><C8A1>ί<EFBFBD>У<EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֮<EFBFBD><EFBFBD>ʹ<EFBFBD><EFBFBD>ί<EFBFBD>й<EFBFBD>ϵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӿڱ<EFBFBD>д<EFBFBD><EFBFBD><EFBFBD><EFBFBD>򵥵<EFBFBD>ί<EFBFBD>к<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD>ί<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̳<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>