按 ‘ 2012年04月25日 ’ 归档

Bug-free development: Understand the differences between the physical world and the computer world

It is important to understand the differences between the physical world and the computer world, and keep the differences in mind.

A computer, most times, is only simulating the actual world. As a result, if the simulation is not well designed, then a program may get incorrect, inaccurate, and/or inconsistent result. A function once worked one month ago may no longer work today, or its behavior varies from one computer to another. If I said these in front of a programmer, he/she would probably agree. This does not mean he/she would keep this in mind, though. I have seen many cases when the program inaccurately simulated the world, its master’s first instinctive reaction was to check somewhere else, but not their own code.

  • In the physical world there are axioms and laws, while in the computer world there are standards and conventions.
  • In the physical world there are math and physics, while in the computer world there are algorithms.
  • In the physical world numbers can be infinitely large or infinitely small, while in the computer world numbers are represented by limited bits.

When writing programs, the developer have to keep alert of these differences, and when introducing his/her code to others, he/she can easily tell which items are representing the physical world, and which can stand true only on a computer.
猛击阅读全文