Hi!
I think it would be useful to include a definition of “Refactoring” in the lesson video for those students who have never heard the term before. One I like is:
Refactoring is improving the structure of the code without changing its functionality.
Cheers!
3 Likes
Refactoring means moving code around so it is easier to read, sometimes to prevent duplication, other times it can be rewriting a bit of code to be simpler so you don’t have a nest of if statements and other things going on.
For example you could have (in serious pseudo code here :P)
if(ends in 0)
do stuff()
if(ends in 1)
do stuff()
if(ends in 2)
do other stuff()
if(ends in 3)
do stuff()
this could be refactored to
if(ends in 2)
do other stuff()
else
do stuff()
You see how that is now more readable and easier to understand? That is one method of refactoring.
Another one as I said, is removing duplicate code, so say you have (again, in major pseudocode :P)
if(hit thing) {
do stuff()
do some other stuff()
}
if(other thing hit) {
do stuff()
do some other stuff()
}
You could refactor this in to
if(hit thing) {
dothing()
}
if(other thing hit) {
dothing()
}
void dothing() {
do stuff()
do some other stuff()
}
This then centralises your code and makes it all in one place without duplication, again making the code tidier 
I hope that makes sense!
1 Like
I was going to ask what it meant since he didn’t talk about it and just duplicated a line of code in the video.
Thanks Andres_Ornelas and refractionpcsx2 for bringing this up and for that great explanation.