- Python 3 Object:oriented Programming(Second Edition)
- Dusty Phillips
- 300字
- 2021-07-16 20:44:31
Exercises
Write some object-oriented code. The goal is to use the principles and syntax you learned in this chapter to ensure you can use it, instead of just reading about it. If you've been working on a Python project, go back over it and see if there are some objects you can create and add properties or methods to. If it's large, try dividing it into a few modules or even packages and play with the syntax.
If you don't have such a project, try starting a new one. It doesn't have to be something you intend to finish, just stub out some basic design parts. You don't need to fully implement everything, often just a print("this method will do something")
is all you need to get the overall design in place. This is called top-down design, in which you work out the different interactions and describe how they should work before actually implementing what they do. The converse, bottom-up design, implements details first and then ties them all together. Both patterns are useful at different times, but for understanding object-oriented principles, a top-down workflow is more suitable.
If you're having trouble coming up with ideas, try writing a to-do application. (Hint: It would be similar to the design of the notebook application, but with extra date management methods.) It can keep track of things you want to do each day, and allow you to mark them as completed.
Now, try designing a bigger project. It doesn't have to actually do anything, but make sure you experiment with the package and module importing syntax. Add some functions in various modules and try importing them from other modules and packages. Use relative and absolute imports. See the difference, and try to imagine scenarios where you would want to use each one.
- CentOS 7 Server Deployment Cookbook
- ADI DSP應(yīng)用技術(shù)集錦
- Nginx實(shí)戰(zhàn):基于Lua語(yǔ)言的配置、開(kāi)發(fā)與架構(gòu)詳解
- Spring快速入門(mén)
- Spring Boot實(shí)戰(zhàn)
- Access 2010數(shù)據(jù)庫(kù)應(yīng)用技術(shù)實(shí)驗(yàn)指導(dǎo)與習(xí)題選解(第2版)
- Software-Defined Networking with OpenFlow(Second Edition)
- SAP Web Dynpro for ABAP開(kāi)發(fā)技術(shù)詳解:基礎(chǔ)應(yīng)用
- Go Systems Programming
- Java面向?qū)ο蟪绦蛟O(shè)計(jì)教程
- Learning TypeScript
- LabVIEW數(shù)據(jù)采集(第2版)
- Instant AppFog
- JavaScript程序設(shè)計(jì)實(shí)例教程(第2版)
- Responsive Web Design with HTML5 and CSS3(Second Edition)