Monday, April 24, 2006

Errors & Bugs

Errors & Bugs

Absolutely all of us face errors in writing programs (Compilation and runtime and others). Some give up some make massive changes while others try to follow errors and never change code or idea.really I don't know what is the best choice but I think it depends on the project itself and on the programmer.

Well I will tell you about some errors I faced.

First error: When I compiled a project (signal flow graph) a nice error appeared.The error was multiple declaration for class List see earlier declaration actually they were more than one error. I compiled the program more than once but the same error List was a template class so I thought that was because of template errors or due to multiple inclusions from several files. All didn’t work. Finally I decided to trace the earlier declarations. I found that the earlier declaration was in other project (Sorting techniques) although the project file was not included. WOW! Yet I was very pleased that I closed the computer. Never work in 2 projects in the same time simply, delete one of them to be far from errors.
No comment.

Other error was in sorting techniques project the project compiled normally with 0 errors and some warnings but when I removed the checkbox of Build with runtime packages the following error appeared fatal linker error cannot find the file “perfgrap.obj”!! What is that file and who included it I don’t know? When I removed the checkbook the project compiled normally I made a new project added all files to that and compiled it with the same error so, what to do now?? I had a small idea I brought any object file from any project and copied it to the project directory then renamed it to “perfgrap.obj” then compiled the project. It compiled successfully and ran normally!
Past errors were all compilation errors what about run time errors?
One of the strangest errors I saw was privileged instruction error! I think it was the responsibility of the compiler to fix that error. other was Paging file error when I see this types of errors I do nothing more than compiling the project more than once.

What’s an error?

(Compilation) Not following the language rules.
(Runtime) The condition of preventing the program from continuing running normally.

What’s a bug?
A bug is a mistake or failure that prevents it from working normally or produces incorrect or false result.
Linus Travold "Given enough eyeballs, all bugs are shallow".
Advices for programmers:

1-Write smart compressed small code : e.g. to copy a string: while (*s++ = *t++) ;
2-Go back and enhance your old code.
3-Learn from your IDE.( Language features IDE features help…)
4-Development on a fast-super computer.
5-Write lots of comments.
6-Use accessors or properties rather than public data.
7-Be aware with input and organized with output.
8-All special cases must be handled immediately; you'll never go back and fix them.
9-Design first (on paper in mind) then code.

No comments: