Refactoring Workbook

Interlude 1. Smells and Refactorings

I1.2. Refactorings that Fix the Most Smells

Move Method, Extract Class, Move Field , and Extract Method

I1.3. Refactorings Not Mentioned

It's a long list. Some are just code manipulation; it's not that either way smells, but rather the refactoring provides a safe way to move between two valid alternatives. Others are a bit specialized ( especially the "big" refactorings). Others are used as steps in applying another refactoring; the smell for the other refactoring triggers this one.

I1.4. Other Smells

Everybody's list will be different. I added these:

  • Intertwined Model and UI ” Duplicate Observed Data, Separate Domain from Presentation

  • Cast ” Encapsulate Downcast

  • Unclear Communication ” Remove Assignment to Parameter, Replace Error Code with Exception, Replace Exception with Test, Replace Magic Number with Symbolic Constant, Split Temporary Variable

  • Conditional Logic ” Consolidate Conditional Expression, Consolidate Duplicate Conditional Expression, Introduce Null Object, Replace Error Code with Exception, Replace Exception with Test, Replace Nested Conditional with Guard Clause, Replace Conditional with Polymorphism.

Категории