Effective PyCharm Transcripts
Lecture: Refactoring introduction
0:03 Hello again. I am so very excited about this chapter.
0:07 Refactoring is one of my absolute favorite topics.
0:10 Why? Because I see so many people start to write software and then they get
0:15 frozen in place thinking oh well what if I'm doing it wrong And what if in
0:19 the future we need this other feature or there's other ways to write this part of
0:23 the program and they just get stuck when they spend so much time thinking and worrying
0:28 about getting started. Instead of just getting started.
0:31 And with refactoring we can make some progress,
0:34 we'll learn a bunch more about the problem we're trying to solve and then we can
0:38 apply refactories changes to our code that changed the structure or the architecture without actually
0:44 changing the behavior. We can apply these refactoring to make it better.
0:48 So instead of getting stuck with analysis,
0:50 paralysis or worrying too much about how to get started.
0:54 Just get started and apply what you learn in this chapter to keep you on track
0:58 That's the way real software is built.
1:01 So we're gonna see as we write our code,
1:04 there'll be problems like there'll be a method that's 500 lines long.
1:07 There'll be variables that have very poor names,
1:09 methods that have poor names, methods that should be broken apart.
1:14 Class hierarchies that contain the abstractions at the wrong level.
1:17 All kinds of things that we can do to move code around automatically with PyCharm.
1:22 Now I want to be super clear here.
1:24 This is not some sort of advanced find and replace.
1:28 Not at all that could find just duplicates of names.
1:32 they don't actually have any relationships across our files and wreck our program.
1:36 Know what this is, is PyCharm,
1:38 loads up all the files in our project.
1:40 It turns it into an abstract syntax tree where it understands the actual relationships between the
1:46 symbols and code. And when you apply those changes those re factories,
1:49 it's not based on names, it's based on how the code actually works.
1:54 So it's really, really reliable and it truly understands what's going on.
1:58 So fantastic tools in PyCharm for refactoring.
2:02 I think it's such an important skill to master and to know about and the tools
2:06 are great. So we're going to dive into it and see how to apply them
2:09 to some examples in this chapter.