what are code smells
what is refactoring
refactoring flow
when to refactor
types of code smells
what is self documenting code
excessive use of comments to explain unnecessary complex structures
reduce the need for supplementary documentation
extract method
pros
- more readable code
- less duplication
inline method
pros
- minimise number of unneeded methods
move method
pros
- reduce dependency between class
extract class(split)
pros
- single responsibility class are more reliable, tolerant to changes
inline class
pros
- eliminate needless class
encapsulate fields
PRIVATE String name
pros
- bring data closer together
replace data with class
pros
- group primitive data types into its own class
replace magic number with symbolic constant
pros
- reduce duplicate use of number or string
replace method with class
pros
- isolate long method
cons
- another class is added which increases complexity
parameterise method
pros
- combine multiple methods by using parameters
remove parameters
pros
- method only contain parameters it truly requires
introduce parameter objects
pros
- replace repeating group of parameter with class