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

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.

00:45 This would only be for the dog, or maybe you have some other animals that can also run and fetch things. I’ve heard pigs are pretty smart, so maybe you could teach it to a pig.

00:55 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.

01:08 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.

01:21 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:24 You can also add a .__repr__() to your classes. You’ve seen me work only with .__str__(), which is the string representation to give you readable output on an object.

02:34 The .__repr__() is something to create a representation that theoretically you should be able to just paste the string that it outputs to create that object.

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.

03:04 So these are some ideas that you could tackle next in terms of how to improve your code and how to continue learning on the base of your farm model. Also, some other development techniques.

03:15 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 .__repr__() versus .__str__() so that you know the difference between those two.

03:31 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.

03:43 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.

03:57 I think you’ve got a lot that you could go forward and work on, but also if you’re done with this specific farm model, I think you did a great job up to this point.

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.

04:22 In the next lesson, you’ll get the promised bug fix for the .move() method. Let’s check that out.

Become a Member to join the conversation.