This print for content only-size & color not accurate 7" X 9-1/4" / casebound / malloy


Ode to Errors, Bugs, and Exceptions



Download 21,46 Mb.
Pdf ko'rish
bet448/1830
Sana28.09.2021
Hajmi21,46 Mb.
#188411
1   ...   444   445   446   447   448   449   450   451   ...   1830
Bog'liq
[book] [en] Pro C# 2008 and the NET 3.5 Platform Fourth Edition

Ode to Errors, Bugs, and Exceptions

Despite what our (sometimes inflated) egos may tell us, no programmer is perfect. Writing software

is a complex undertaking, and given this complexity, it is quite common for even the best software

to ship with various . . . 



problems. Sometimes the problem is caused by “bad code” (such as over-

flowing the bounds of an array). Other times, a problem is caused by bogus user input that has not

been accounted for in the application’s code base (e.g., a phone number input field assigned to the

value “Chucky”). Now, regardless of the cause of said problem, the end result is that your applica-

tion does not work as expected. To help frame the upcoming discussion of structured exception

handling, allow me to provide definitions for three commonly used anomaly-centric terms:



Bugs: These are, simply put, errors on the part of the programmer. For example, assume you

are programming with unmanaged C++. If you fail to delete dynamically allocated memory

(resulting in a memory leak), you have a bug.



User errors: Unlike bugs, user errors are typically caused by the individual running your

application, rather than by those who created it. For example, an end user who enters a mal-

formed string into a text box could very well generate an error if you fail to handle this faulty

input in your code base.



Exceptions: Exceptions are typically regarded as runtime anomalies that are difficult, if not

impossible, to account for while programming your application. Possible exceptions include

attempting to connect to a database that no longer exists, opening a corrupted file, or con-

tacting a machine that is currently offline. In each of these cases, the programmer (and end

user) has little control over these “exceptional” circumstances.

Given the previous definitions, it should be clear that .NET structured exception handling is a

technique well suited to deal with runtime 



exceptions. However, as for the bugs and user errors that

have escaped your view, the CLR will often generate a corresponding exception that identifies the

problem at hand.

219

C H A P T E R   7

8849CH07.qxd  10/1/07  10:38 AM  Page 219



The .NET base class libraries define numerous exceptions such as FormatException,

IndexOutOfRangeException, FileNotFoundException, ArgumentOutOfRangeException, and so forth.

Within the .NET nomenclature, an “exception” accounts for bugs, bogus user input, and runtime

errors, even though we programmers may view each possibility as a distinct issue. However, before

we get too far ahead of ourselves, let’s formalize the role of structured exception handling and check

out how it differs from traditional error-handling techniques.




Download 21,46 Mb.

Do'stlaringiz bilan baham:
1   ...   444   445   446   447   448   449   450   451   ...   1830




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