Monday, August 12

Warnings in your code

In industry, there is a statistics that every x warnings contain one fatal error that will require you a lot of time/money to debug/fix and recover lost.

There are some warnings that are harmless. You know that, so you think you can ignore them.

When you start ignoring warnings in your code, you start accepting that your code is messy, lousy, and you stop caring for it. That is how the real problem starts. When a fatal warning is created, you don't see it. Several months later, you will find yourself in a situation that your previous work were based on wrong result, and you don't know how you have come so far.

So if you know the warning is harmless, and it is expected, then you should explicitly spell that in your code to suppress the warning. Don't abuse this method though.

If you are using Matlab, the editor gives warning for the lines that don't have ";" sign to complete. If you actually wanted to show the result of that line, please use ";" to complete that line, then use disp() to explicitly show the result.

This way, only the unexpected warnings are left in your code, and you can focus on them to remove them one by one.

A mature system should disallow any warning in the production code.

Programmers are the only species that ignore warnings and fell off the cliff.