You can think of logic errors as hidden errors. In general it will not produce any kind of err msg. Instead, a logic error will produce what programmers usually call “undesirable results”.
For ex: Sales tax calculations. Miscalculated sales tax can even cause serious legal and financial problems.
We can prevent some logical errors by clear cut of requirements and design specifications, and some more logical errors can still creep into code. Make use of “plus” operator instead of “minus” or some other operator which is actually have to use.
Another preventative measure against logic errors is what is known as defensive programming. It is about checking assumptions about the expected program flow and either
1. generating runtime errors 2. Including extra code
Particularly complex problems in the form of procedures, functions, classes and so on.
No comments:
Post a Comment