Καλώς ορίσατε στο dotNETZone.gr - Σύνδεση | Εγγραφή | Βοήθεια

On Error Resume ... what?

    Imagine a form. A VB6 form. The form has a couple dozen controls. It also has a couple dozen methods. Each method has a couple hundred lines of code (net, no comments). Each method may call a half dozen other methods, except some thousand-liners that call almost half of all the methods.

 

And there is no centralized error handling.

 

    Nothing. Nada. Zip. In fact, there is no real error handling code at all. Each method returns either an exit code or a default value. Their callers have to check the return codes or guess whether the default return value is a normal value or the result of an error. Some may even return error messages instead of codes. And while the programmers were generally quite diligent in checking the result codes, some error conditions  inevitably go unnoticed. Until a customer notices them, that is.

    Now, the methods do log the errors before returning the error codes. Only, they don't all do it the same way. Some log their names and the error description, others just a generic error message. Few do log the source of the error. For the thousand liner methods, this means that it is almost impossible to locate where the error occurred!

 

    Now, the programmers should make sure they always check the return values. They should always log all the appropriate error info. And they should always return the agreed-upon result codes. But people make mistakes. They can't help it. There will always be some unchecked return values and what happens then? The necessary cleanup code isn't executed, invalid values are produced. At best, this will cause the code to throw another error later on, only the root cause will be unknown. Usually , the incorrect results will travel all the way to the end user, resulting on some quite entertaining expletives from the end user and some rather unflattering comments regarding the programmers' ancestry. At worst, the invalid results may we go unnoticed and result in significant financial losses and legal trouble.

    Have you ever heard about the granny that was charged 50,000 € for electricity? Or the guy that bought a new stereo for only 3.00 €? Would you like to be the customer whose bank account was deleted when he deposited just enough to cover his overdraft?

 

Would you feel safe using that code? Or, maybe even modify it to add new functionality?

Έχουν δημοσιευτεί Πέμπτη, 14 Δεκεμβρίου 2006 10:40 μμ από το μέλος Παναγιώτης Καναβός

Ενημέρωση για Σχόλια

Αν θα θέλατε να λαμβάνετε ένα e-mail όταν γίνονται ανανεώσεις στο περιεχόμενο αυτής της δημοσίευσης, παρακαλούμε γίνετε συνδρομητής εδώ

Παραμείνετε ενήμεροι στα τελευταία σχόλια με την χρήση του αγαπημένου σας RSS Aggregator και συνδρομή στη Τροφοδοσία RSS με σχόλια

Σχόλια:

Χωρίς Σχόλια

Ποιά είναι η άποψή σας για την παραπάνω δημοσίευση;

(απαιτούμενο)
απαιτούμενο
(απαιτούμενο)
ÅéóÜãåôå ôïí êùäéêü:
CAPTCHA Image