Bummer! This is just a preview. You need to be signed in with a Basic account to view the entire video.
Start a free Basic trial
to watch this video
Refactoring is a process that naturally follows the initial coding stage, where you go back through your program and make what you wrote more concise and readable.
-
0:00
We've created an app that behaves the way we want.
-
0:02
So it's tempting to think the work is done.
-
0:05
But what if you or someone else needs to change this app in the future?
-
0:09
If you don't organize your code well, it could be challenging for
-
0:11
someone else to step in and understand how the program works.
-
0:14
It could even be challenging for you to return to some of your old programs
-
0:18
if you didn't take the time to organize their code.
-
0:21
When you're working on a project, your mind often moves around in creative and
-
0:25
wandering ways.
-
0:26
Your code follows where your mind goes, that's a good thing, and
-
0:29
it can help you come up with creative solutions you didn't think of
-
0:32
when you first planned out your program.
-
0:34
But when you solve those problems, it's important to go back and
-
0:37
clean up your code.
-
0:39
This is called refactoring.
-
0:40
And it's the process of rewriting code while leaving the original
-
0:44
behavior exactly the same.
-
0:46
In other words, when you're done refactoring,
-
0:48
nothing to change in the way your app behaves externally.
-
0:51
But your code should be easier to read, easier to update, and
-
0:54
maybe even work more effectively and efficiently.
-
0:56
So let's look at our app and see what opportunities there might be for
-
0:59
cleaning up our code.
You need to sign up for Treehouse in order to download course files.
Sign up