Explore Additional Ideas
00:00 So at this point, I’m done with this challenge. I modeled the farm. I’m happy with the output, and I hope you’re happy with what you got as well. You can download the code that I wrote in this course from the Supporting Material dropdown under the Sample Code (.zip) option.
00:17 It doesn’t fit on the slide, so make sure to go there and download it if you’re interested in exploring the code some more. Of course, you can use it as a base also to extend it and build out the farm model a little more. Here’s a couple of ideas of what you could do.
00:32 You could model food as classes and then have food objects that you can feed to your animals, and maybe they get more full or happier depending on which food you feed to them. You could model things to fetch as classes.
You can, of course, add more instance methods to your other child classes as well, or maybe additional instance methods to the
Dog class. Get creative with what you would be interested to see your animals do.
Of course, you could add more animals. That should be a matter of just creating a new child class inheriting from
Animal. And then maybe you want to extend some of the methods or create new instance methods, and you can add more farm locations.
Maybe you want to model the farmhouse as well, or some other outdoor habitats for your animals. See whether you can make them inherit from
FarmLocation, and when you’re going to run into some sort of limitation because of the abstraction, you can see you can continue working on this and build it out as much as you want to.
01:41 I have some other ideas for you as well that are not related to just growing the model of your farm, but instead things that would make your code maybe more stable and also teach you some additional things regarding development in Python.
01:55 And those ideas would be to write tests for your farm. So, you’ve seen me test all of the code that I wrote manually in the interactive shell, but re-creating all these instances of animals and farm locations kind of gets tedious with time, and also it’s error-prone.
02:12 So, one way to circumvent this would be to write tests that you can then just run automatically and see whether everything still works the way that you expect it to. So that’s a great next step that you could take.
02:44 And I’ve also mentioned that it’s not ideal that you’re constantly returning strings from your methods because I’ve been kind of using them as logging output just to get a sense of what’s happening when I work with these different objects. And it might be better if you use logging for that instead and then return more useful objects.
Here’s some resources for those suggestions that are code related. A tutorial and the video course on getting started with testing. Then there’s an article on when you should use
.__str__() so that you know the difference between those two.
And then we also have a tutorial and the video course on logging in Python and maybe an interesting tutorial about Python logging that explores the
logging module from an object-oriented perspective.
And then also we have an article and the video course on the Python
return statement. So what is a good thing to return and how you could change that in the methods of your class? And that’s it for additional ideas.
04:07 There’s no need to continue working on that. There’s always going to be a new project, but if you’ve enjoyed working with it, then maybe these are some additional ideas that if you want to implement, then go ahead and do that. That’s nearly it for the course.
Become a Member to join the conversation.