Author Dusty Phillips Reviewers



Download 2,95 Mb.
Pdf ko'rish
bet149/183
Sana20.07.2022
Hajmi2,95 Mb.
#831085
1   ...   145   146   147   148   149   150   151   152   ...   183
Bog'liq
python3-oop

[
 154 
]
Which version do you find easier to use? Which is more elegant? What is easier to 
read? These are subjective questions; the answer varies for each of us. Knowing the 
answer, however, is important; if you find you prefer inheritance over composition, 
you have to pay attention that you don't overuse inheritance in your daily coding. If 
you prefer composition, make sure you don't miss opportunities to create an elegant 
inheritance-based solution.
Finally, add some error handlers to the various classes we created in the case study. 
They should ensure single characters are entered, that you don't try to move the 
cursor past the end or beginning of the file, that you don't delete a character that 
doesn't exist, and that you don't save a file without a filename. Try to think of as 
many edge cases as you can, and account for them (thinking about edge cases is 
about 90 percent of a professional programmer's job!) Consider different ways to 
handle them; should you raise an exception when the user tries to move past the
end of the file, or just stay on the last character?
Pay attention, in your daily coding, to the copy and paste commands. Every time
you use them in your editor, consider whether it would be a good idea to improve 
your program's organization so that you only have one version of the code you are 
about to copy.
Summary
In this chapter, we focused on identifying objects, especially objects that are not 
immediately apparent; objects that manage and control. Objects should have both 
data and behavior, but properties can be used to blur the distinction between the 
two. The DRY principle is an important indicator of code quality and inheritance
and composition can be applied to reduce code duplication.
In the next chapter, we'll cover several of the built-in Python data structures and 
objects, focusing on their object-oriented properties and how they can be extended
or adapted.
www.it-ebooks.info



Download 2,95 Mb.

Do'stlaringiz bilan baham:
1   ...   145   146   147   148   149   150   151   152   ...   183




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish