Draw Your Idea
00:00 In this lesson, I’ll try to sketch out some ideas that I have for how I might build the model of my farm. Drawing is a great way to brainstorm and to get a better feel for what the task you’re trying to tackle is all about.
These are going to be the three instance methods that I’m going to implement and I’ll implement them in the
Animal parent class. And then each of the child classes are going to have access to them.
Okay, so this looks pretty nice for now. Maybe there’s going to be some class attributes I’m not thinking about right now, but I think this is an idea of modeling an
Animal class and then three subclasses.
And I also, I’m going to want to keep track of which animals are in a location. So I will use some sort of attribute here,
.animals, and this is going to be interesting because that’s going to map to
Animal objects can be part of such a
FarmLocation. And this is badly drawn Ro boy. I guess here we’re talking about composition, right? So this is a, has a relationship which is composition, or specifically in this case it’s aggregation because this
FarmLocation can also not have any animals in there.
04:39 Spaces how many animals can fit in a field or in a barn. And I’ll initialize that when I create the instances of these classes. And I’m sure I forgot something, but this is going to be can I’m like my working scribble that I’m going to go off on and then see what happens when I try to convert it into code.
05:00 And keep in mind that drawing such a diagram, it doesn’t have to be perfect at all. This is really just a way for you to organize your brain a bit and try to think about what are you probably going to do in your code.
05:12 And it helps you to guide your coding and maybe already catch a couple of mistakes or avoid them, or at least have a path that you can follow when you start coding and it’s going to make it easier to develop your classes.
Become a Member to join the conversation.