Bad Smells in code
Bad Smells in code
Refactoring
Defining Refactoring
Refactoring (noun): a change made to the internal
structure of software to make it easier to understand
and cheaper to modify without changing its
observable behavior.
Tip
• data migration
changing the database schema forces you to
migrate the data
• important exception
when you explicitly do not want to create a
dependency from the called object to the larger
object
Unpacking data and sending it along as
parameters is reasonable
Solution
Divergent Change
• one class is commonly changed in different
ways for different reasons.
• identify everything that changes for a
particular cause
• Use Extract Class to put them all together.
Divergent change
Solution
Shotgun Surgery
• every time you make a kind of change, you
have to make a lot of little changes to a lot of
different classes
Opposite of divergent change
easy to miss an important change.
Move Method and Move Field to put all the
changes into a single class
Inline Class
• Unnecessary delegation
Inline Class