Sometimes when programing we have to resolve some simple arithmetic problems, like calculating the remainder elements from a buffer, counting the numbers of elements, etc. In these cases is easy to commit "off by one" mistakes, ie we account one element more or one less. In the better case we are lucky if the program crash in the right place, but we often end up with a bug that is really hard to find.
One trick that I find often useful in these situations is to think that the buffers are much smallers, like zero or one bytes; another option is to think a large and easy number like 1000, etc.
Y el premio para el camino más corto es para…
Hace 3 días.
No hay comentarios.:
Publicar un comentario