Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
What is ASSERT used for?
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00141677
Message ID:
00141788
Vues:
49
Hi Mark,

>By catching errors with assertions, and turning that checking off for the final product, you are saying your code contains no bugs that those assertions trapped, aren't you? Either that, or you'll take that chance over the speed hit.

With all respect, Mark, I think you're mixing up to concepts here. :)

ASSERT is a debugging and a testing tool. What it traps should never occur during execution (in theory). ASSERT is used during development to find these impossible situations, it makes integration easier, and so on.

The other concept is defensive programming. Defensive programming lets a program behave more stable by counting in for impossible situations and try to deal as best as possible with them. For example by loading files, using default values, or simply passing an error message to the calling method. If there's no other possibility, it halts the program execution to prevent more serious problems. Defensive programming by itself hides bugs and therefore inherentily makes programs more buggy.

In other words, ASSERT reduces bugs, defensive programming increases stability. ASSERT is used during development, defensive programming during runtime. Of course this requires that often a condition is checked twice, but with different intentions.

Christof
--
Christof
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform