Week 10
Week 10
SOFTWARE RE-ENGINEERING
Making Refactoring Safe
How do you make
refactoring safe?
1
Use Refactoring “Patterns”
TIP
“Three strikes and you refactor”.
1
Refactor when you add function
The most common time to refactor is when you want to add a new
feature
It’s like I want to go 100 miles East but instead of just traipsing through
the woods, I’m going to drive 20 miles north to the highway and then I’m
going to go 100 miles East at three times the speed I could have if I just
went straight there. When people are pushing you to just go straight
there, sometimes you need to say, “Wait, I need to check the map and
find the quickest route.” The preparatory refactoring does that for me.
2
Refactor when you need to fix a bug
• In fixing bugs much of the use of refactoring comes from making code
more understandable
• if you do get a bug report, it's a sign you need refactoring
• the code was not clear enough for you to see there was a bug
3
Refactor as you do a code review