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

Upload: cgty-ulsy

Post on 24-Dec-2015

32 views

Category:

Documents


1 download

DESCRIPTION

Code refactoring

TRANSCRIPT

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