Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

This lesson is for members only. Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Refine Plan for Move Method

00:00 Let’s start tackling these tasks. And when I read over these, I actually have the feeling there’s maybe two more high-level parts of this that I want to tackle.

00:11 One is that I want to make sure that I do some of these actions before updating self._location, the current one that is set. And then I want to do some after updating it.

00:31 So these are a bit more high-level separations here. I want to exit the location that it’s in before updating self._location.

00:43 And also I want to don’t enter if it’s already in there.

00:54 I have the feeling this is maybe a good higher-level separation in here. First, I want to make sure that it’s not already in the location that I’m trying to move it to. Then if it isn’t in that location, but it’s in a different location, I want to exit that location. At that point, I’m ready to update self._location for the Animal instance and make sure that it points to the new location.

01:18 And then after updating this, I want to enter it if it’s not full. So I guess that first check, let’s rephrase this a bit.

01:31 Check whether the location is full and enter into a location if it’s not full, because I already checked whether it’s not there earlier. Okay, that seems like a good update.

01:45 I think this kind of like high-level separation is going to make it a little easier to write the code and for me at least to conceptualize what I’m supposed to do in here and also when I’m supposed to do the different steps, because it seems like they have some sort of logical order to it that I first want to do a couple of checks, then update self._location and then do a bit more processing where I’m going to make sure that in both of the objects, the relevant attributes are updated accordingly.

02:15 Okay. Second planning step out of the way. In the next lesson, I’m going to start tackling the first part with these two tasks that we’ve just written out here.

Become a Member to join the conversation.