- Python 3 Object Oriented Programming
- Dusty Phillips
- 457字
- 2021-08-03 15:36:06
Exercises
This is a practical book, not a textbook. As such, I'm not about to assign you a bunch of fake object-oriented analysis problems to create designs for. Instead, I want to give you some things to think about that you can apply to your own projects. If you have previous object-oriented experience, you won't need to put much effort into these. But they are useful mental exercises if you've been using Python for a while but never really cared about all that class stuff.
First, think about a recent programming project you've completed. Identify the most prominent object in the design. Try to think of as many attributes for this object as possible. Did it have: Color? Weight? Size? Profit? Cost? Name? ID number? Price? Style? Think about the attribute types. Were they primitives or classes? Were some of those attributes actually behaviors in disguise? Sometimes what looks like data is actually calculated from other data on the object, and you can use a method to do those calculations. What other methods or behaviors did the object have? What objects called those methods. What kinds of relationships did they have to this object?
Now think about an upcoming project. It doesn't matter what the project is; it might be a fun free-time project or a multi-million dollar contract. It doesn't have to be a complete application; it could just be one subsystem. Perform a basic object-oriented analysis. Identify the requirements and the interacting objects. Sketch out a class diagram featuring the very highest level of abstraction on that system. Identify the major interacting objects. Identify minor supporting objects. Go into detail for the attributes and methods of some of the most interesting ones. Take different objects to different levels of abstraction. Look for places you can use inheritance or composition. Look for places you should avoid inheritance.
The goal is not to design a system (although you're certainly welcome to do so if inclination meets both ambition and available time). The goal is to think about object-oriented designs. Focusing on projects that you have worked on or are expecting to work on in the future simply makes it real.
Now visit your favorite search engine and look up some tutorials on UML. There are dozens, so find the one that suits your preferred method of study. Sketch some class diagrams or a sequence diagram for the objects you identified earlier. Don't get too hung up on memorizing the syntax (after all, if it is important, you can always look it up again), just get a feel for the language. Something will stay lodged in your brain, and it can make communicating a bit easier if you can quickly sketch a diagram for your next OOP discussion.
- Painter 現代服裝效果圖表現技法
- TArch 8.5天正建筑軟件標準教程
- 商用級AIGC繪畫創作與技巧(Midjourney+Stable Diffusion)
- 鍵盤錄入技術(第2版)
- GlassFish Administration
- 計算機圖形圖像處理Photoshop CS6項目教程
- Premiere pro CC中文版自學視頻教程
- Autodesk Ecotect Analysis綠色建筑分析應用
- PPT設計與制作實戰教程
- Photoshop+CorelDRAW平面設計案例實戰:從入門到精通(視頻自學全彩版)
- 中文版Photoshop平面設計入門教程
- Apache JMeter
- UG NX 11中文版從入門到精通
- SPSS統計分析與應用
- Inkscape 0.48 Essentials for Web Designers