Refactoring Notes

8
1- Extract Method Code Smells -> Extract Method 1- Long methods 2- Comments If a section needs a comment to explain it instead of commenting write a new method

description

Code refactoring

Transcript of Refactoring Notes

1- Extract Method

Code Smells -> Extract Method

1- Long methods2- Comments

If a section needs a comment to explain it instead of commenting write a new method

Inline Method Refactoring

Replace temp with Query

Dont use the same temp for different reasons! -> Split Temporaryi Variable!

Introduce Explaining Variable -> Pure readibility

Remove Assignments to Parameters: (Beware of the impact of any change to the assignment)

“feature envy” a method is more interested in reaching into a different class accessing data.

REPLACE CONDITIONAL WITH POLYMORPHISM

REPLACE TYPECODE WITH SUBCLASSES!

Minimize parameter list!

Avoid doing more than at the same method -> split queries!

1- LENGTH 2- COMMENTS 3- CHECK SWITCH STATEMENTS