Rock Solid Python with Python Typing Transcripts
Chapter: Typing Guidance, Patterns, and Advice
Lecture: Refactoring Motivation

Login or purchase this course to watch this video and the rest of the course contents.
0:00 The next advantage for types I want to talk about has to do with refactoring. Now, for some people, refactoring means I'm changing my code.
0:09 It was like this, now it's like that. No, refactoring has a more constrained meaning. And so I want to be real careful,
0:17 just in case you've kind of been using it loosely. It means changing the structure of the code, changing the code so that it behaves
0:24 in exactly the same way as it did before, but maybe it's cleaned up in some way, maybe it's more readable, maybe it's split into smaller functions,
0:35 maybe it's split across modules, whatever, right? But it's just, I'm changing the code in a way that doesn't change its behavior from the outside.
0:42 Okay, so that's something you want to do all the time. One of the problems people have writing code is they overthink, they dramatically overthink,
0:52 how should it be designed? How should we use this? We don't want to get it wrong, because if we get it wrong, it's going to be real bad.
0:59 No, it might be a little bit bad, but it won't be real bad, because we have awesome tools. Like in PyCharm, you right-click,
1:07 rename this function, move that into a class, move that to another module, combine these, split those, all that stuff.
1:14 Code is plastic when you're working with the right tools. It's malleable, it can be formed and reformed. And one of the things you don't want to do
1:23 is you want to run into trouble with all of your type systems. So refactoring tools love types. Let's see that.


Talk Python's Mastodon Michael Kennedy's Mastodon