Sunday, 13 March 2011

Bugs

Systematic bugs: Due to some misunderstanding of the syntax or grammar of the programming language.

Random Bugs: Your bugs that you didn't know about.
Defined as either problems WITH your thinking or problems that materialized from the process of turning thinking into code.

Problems with thinking just have to do with unclear thinking, or even misunderstanding your own thinking.
Problems from thinking to code have to be sorted out by making the process as transparent and traceable as possible without ambiguity, so that little issues all become apparent.

Debugging aids are not optional. They are actually necessary, yet in the coding frenzy we have to put everything down on the source files, we forget that we must be able to repeat all the thinking in its entirety. Now, some people are less prone to human errors, but given a long enough program, everyone will make errors.
Testing is useful only if you know what you're doing. While it closes the gap between actual results and desired results, it cannot be a substitute for transparency in the coding process.

Combining testing and the coding/documentation process gives you the ability to detect all types of bugs. If done perfectly.

Now, even documentation may fail, because even documentation may be wrong. In this case, we try to catch these errors early by debugging certain blocks of code completed. The time taken to find and fix the bug tends to be smaller in a smaller piece of code.

Printing everything out is a classical approach to detect run-time errors and if the program crashes, we get to know where it crashed.

I am trying to implement all this, starting with small coding projects.

These lessons were learned in a painstaking debugging effort, in which I know that these things are the minimum that must be done to make a program generally correct.

3 comments:

Samuel Poon said...

Fortunately for me I don't have to do programming for my course this year. I haven't done any programming in a long while; these days I get by with just simple shell scripts.

For us we're encouraged to do most of the calculations by hand, thereby avoiding any programming / excel errors. Of course it's still likely we made some careless mistakes or wrongly apply the methods.

Come to think of it we have quite a few formulas which solve specific problems, many of which are empirically derived.

Eugene said...

In programming, any mistake is scaled up to ever-increasing proportions.

The objective of testing is to blow the whole operation up to huge proportions so that the errors become apparent.

Eugene said...

Empirically derived?

Interesting...

Wish we had those in computer science but appears that pure math has it covered anyway.