Refactoring Flashcards
what 9 ways are there to refactor methods?
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
what 7 ways are there to simplify conditionals?
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 do you move a method to another class?
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
Which 5 bloaters are there (code smells)?
long method
large class
primitive obsession
long parameter list
data clumps
Which 6 dispensables are there (code smells)?
Comments
duplicate code
lazy class
data class
dead code
speculative generality
Which 4 Object-Orientation abusers are there (code smells)?
switch statements
temporary field
refused bequest
alternative classes with different interfaces
Which 3 change preventers are there (code smells)?
Divergent change
Parallel inheritance hierarchies
shotgun surgery
Which 5 couplers are there (code smells)?
Feature envy
inappropriate intimacy
message chains
middle man
incomplete library class
What 8 ways are there to move features between objects?
Move method
Move field
extract/inline class
hide delegate/remove middle man
introduce foreign method/local extension