Refactoring Flashcards

1
Q

what 9 ways are there to refactor methods?

A

extract / inline method
extract variable
inline temp
replace temp with query
split temporary variable
remove assignments to parameters
replace method with method object
substitute algorithm

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

what 7 ways are there to simplify conditionals?

A

decompose conditional (extract conditional and commands as method)
consolidate conditional expressions
consolidate duplicate conditional fragments
replace nested conditional with guard clauses
replace conditional with polymorphism
introduce null object
introduce assertion

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How do you move a method to another class?

A

verify features used by method, possibly move those, too
copy to new class
change references to old method
delete old method or call new one

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Which 5 bloaters are there (code smells)?

A

long method
large class
primitive obsession
long parameter list
data clumps

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Which 6 dispensables are there (code smells)?

A

Comments
duplicate code
lazy class
data class
dead code
speculative generality

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Which 4 Object-Orientation abusers are there (code smells)?

A

switch statements
temporary field
refused bequest
alternative classes with different interfaces

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Which 3 change preventers are there (code smells)?

A

Divergent change
Parallel inheritance hierarchies
shotgun surgery

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Which 5 couplers are there (code smells)?

A

Feature envy
inappropriate intimacy
message chains
middle man
incomplete library class

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What 8 ways are there to move features between objects?

A

Move method
Move field
extract/inline class
hide delegate/remove middle man
introduce foreign method/local extension

How well did you know this?
1
Not at all
2
3
4
5
Perfectly