chapter 6 Flashcards
what is refactoring?
is the process of changing sw in away that:
- doesn’t change external behavior
- but internal structure is improved
__________ is the art of improving the art of an existing code [ cleaning up ]?
refactoring
what are bad smells?
problem areas due to poor coding and design choices
why should we refactor?
RR II HH P
- reduce redundant code
- reduce complexity
- improves design [ prevents “Decay” ]
- improves code readability
- helps code run faster
- helps find bugs
- provides a more expressive internal structure
which bad smell is due to too many lines of code, or too many parameters?
long method
explain a long class bad smell?
- classes do too much
- reduced cohesion
explain a divergent change bad smell?
- changes require changes in various d/t subsets of methods
- multiple changes are made to a single class
- weak cohesion
which bad smell is the result of a method requiring lots of info from another class?
feature envy
explain a lazy class bad smell?
- class isn’t doing enough to justify its existence
explain a switch case bad smell?
- result in duplicate codes
- can be replaced with polymorphism for a more effective approach
explain a shotgun surgery bad smell?
a single change requires changes to be made to multiple classes simultaneously
what is the opposite of shotgun surgery?
divergent change
explain a data clump bad smell?
is a result of multiple attributes clumped together but not belonging to the same class
explain a parallel inheritance hierarchy bad smell?
addition of a subclass to a hierarchy tree requires similar additions in related hierarchies
which bad smell is often used as a deodorant for bad code?
comments