Refactoring Inhibitors – The Code
Agile
in a Flash by Jeff Langr and Tim Ottinger (card #48)
> Insufficient tests
> Long-lived branches
> Implementation-specific
tests
> Crushing technical debt
> No know-how
> Premature performance
infatuation
> Management metric mandates
--
Agile’s demand for continual
change can rapidly degrade a system’s design. Refactoring is essential to
keeping maintenance costs low in an agile environment.
Insufficient
tests.
TDD gives you the confidence to refactor and do the right thing, when you would
not otherwise for fear of breaking existing code.
Long-lived
branches.
Working on a branch, you’ll plead for minimal trunk refactoring in order to
avoid merge hell. Most branches should be short-lived.
Implementation-specific
tests.
You may want to discard tests, ultimately killing refactoring, if small
refactorings breaks many tests at once. Minimize testto-System Under Test (SUT)
encapsulation violations, which mocks can create.
Crushing
technical debt.
Insufficient refactoring creates overwhelming rampant duplication and difficult
code. Refactor on every green to minimize debt.
No
know-how.
You can’t refactor if you don’t know which direction to take the code. Learn
all you can about design, starting with simple design.
Premature
performance infatuation. Don’t let baseless performance fear stifle
cohesive designs. Make it run, make it right, and only then make it fast.
Management
metric mandates.
Governance by often one-dimensional and insufficient metrics (such as increase
coverage) can discourage refactoring.
-- Do not assume you wrote good
code or did good refactoring. Test, Test and then test again.
No comments:
Post a Comment