Creative Commons Attribution 3.0 Unported License.

11


Gyazo
1. (Missing)
2. (Nonsense)
3. (Honest)
4. (Honest and Complete)
5. (Does the Right Thing)
6. (Intent)
7. (Domain Abstraction)

沿




>

?

(😜)Eclipse60-70%






1.
2.
3.
4.

調
使
使

()

()

Good()

TDD3
3()
()


245


使
1.
2.
3. 使使
4. 使

MissingNonsense
2
(Misleading)
(Missing)


MissingMisleadingNonsense



Part1:
1

Part2: 1
()
使 (bool)

()

Part3: Applesauce
51

(Extract method):
:
:

Applesauce使Applesauce1ApplesauceHonest

Applesauce? !?
?


使

1.
2.
3.
4.
5.


1


使

Bare Honest probably_DoStuffUnrelatedTo{whatever}()]

()

BecomeFroglike()foreach1MakeOne{}BecomeFroglike()

foreachifforeach33

try*_impl()catch()

Misleading

Part1: 使

Part2:
(ex. PageLoad, PreInit)
(ex. GridSquare gridSquare)
(ex. composeNamename)
-er-Util (ex. DocumentManager, CalculationUnit)

Part3: Applesauce
Applesauce

Applesauce

4

2

1

NonsenseHonest
""FAAPreLoad()PreLoad()Applesauce()PreLoadApplesauce()

Applesauce

Honest
11

Part1:

("database", "screen", "network", "service")使

Part2:
1

使dbdb使 probably_doSomethingEvilToTheDatabase_AndStuff()

doSomethingEvilToTheDatabaseprobably__AndStuff? 100%

doSomethingEvilToTheDatabase

1.
2.
3.
4.

31


Part3:
12
?
Rename使Rename使

!
!


handleFlightInfoSomehow()doSomethingEvilToTheDatabase

(Honest and Complete)


Nonsense
Nonsense-Manager-OperationNonsense

? FooFoo? 使1?

HonestHonest and Complete

Honest and Complete1

: 1
: 1_AndStuff

> :


Part1:

Part2:

1. 1()
2.
3.

: 1

Part3:
使

?

2()probably__AndStuff調

213

Part1:
1
1.
2. 1
3. 調

Part2: 調

_AndDoSomethingWIthGraphicsContextAndStuff() 調GCRead Only_AndDoSomethingReadOnlyToGraphicsContextAndStuff()

_AndDoSomethingToDatabaseAndStuff() _AndWriteSomethingToDatabaseAndStuff()

Part3:
_AndStuff_AndStuffHonestCompletely Honest_AndStuff

Completely Honest
Completely HonestHonest

33_AndStuff()31

probably_2132probably_probably_probably_


使

Honest and Complete

_ValidateAllInputs()

4parseXmlAndStoreFlightToDatabaseAndLocalCacheAndBeginBackgroundProcessing()

使
使使
searchHintThenBestMatchSoFarUntilItBecomesReturnValueOrReasonNoMatchWasFound



>

Whole ValuePrimitive ObsessionWhole Value使

Honest and CompleteDoes the Right Thing
Completely Honest 使

Part1:
?

Part2:
2
?
?

Part3:
1Honest and Complete使

?

1) 2) 2Code by RefactoringFix Complex Methods Changes Series2

Fix Complex Methods

1.
2.
3.
4. 3
5. ...AndRecordYield...()...AndCalculateYield...()...AndRecordYieldToService()
6. 3使

1

parseXmlAndStoreFlightToDatabaseAndLocalCacheAndBeginBackgroundProcessing()使

使

使使使

static使

1. 1Foo
2. static
3. FooHonest
4.
5. 使使
6. 使使使
7. public使
8. static
9. 78使
10. 4
11. (ExtractMake Static, Convert to Instance使)
12. 4
13.
14. private
15. public使

使12使210


Does the Right Thing1Split Class1

1使

Does the Right ThingIntent


使




> : 使

使?

HonestHonest and Complete

Honest and CompleteDoes the Right Thing

使調1

> : 使?


()
(Whole Value)
?
?
? 使?

> :

storeFlightToDatabaseAndStartProcessing() beginTrackingFlight()


stopTrackingFlight()

使

2

1.
2. ()使Does the Right Thing
3. (Nonsense)
4. Nonsense
5. 使

Nonsense

Nonsense

使IDESplit Class

Split Class

1. Split Class使
2. Does the Right Thing
3. ()
4. Nonsense
5.
6. 使
7.

Split Class

1. Nonsenseprivate1auto generate使
2. Do the Right Thing
3. undo
4.
5. Does the Right Thing
6. 使
7. 使
8. Split Class3

使shim()

使

RenameUndu

: Nonsense
Nonsense使Nonsense

使/Does the Right Things

Nonsense
使使NonsenseNonsense

使Nonsense使

使Nonsense

Nonsense/Honest and Complete

IntentDomain Abstraction
調

使

>


()

Value Object(Whole Value)

> :


:
1
Thing / ThingIsValid
/Transform,Traversal,Tree, Tail
Manager
Transform
er
Feature Envy:

:
使
begin / end / see progress / poll for data
create / read / update /destroy
source / sink / transform
()

firstName: String
lastName: String
socialSecurityNumber: String
rangeInMeters: int
hardwareModeFlags: int
w

121使

> :


1.
2. 調
3.
4.

> : ValueObject(Whole Value)使

3使
1. MissingNonsense
1. : 使
2. : 使
3. : 使()
2. Find usages使
3.

4使
/
static
(C#)


3(Intent)

4
1.
2. 使
3.
4. 調()
5.
6.
7.


2
1.
2. 使
3. () 使21


gist Combine 2methods into one with a discriminator variable (2Car.Drive())

gist(17)
()


(30)Missing1Honest146Does the Right Thing23

Whole ValueIntent25

3560%使12