Error input.


R. Clayton (rclayton@monmouth.edu)
(no date)


  How should maximum_placement() report an error if the map is incorrect?
  Throw an exception perhaps?

If a calling procedure fails to follow the specifications for the input
parameters, the called procedure is allowed to exhibit arbitrary behavior.
This is a characteristic of a design method known as design by contract,
promoted by Betrand Meyer and supported by the Eiffel programming language.

As a practical matter, I'm of the opinion that code should fail reliably,
obviously, and explicitly. My code generally tends to fail immediately with a
core dump and an informative error message; that way I know exactly where the
error occurred, what the error is, and I have a body to autopsy.

Other people and prefer a less obtrusive approach, such as throwing an
exception. There are some interesting software debates over this matter (such
as: if an unnoticed error occurs in code, is it really there?), but I
constantly tinker with my code (so my errors tend not to remain unnoticed for
long) and I don't have a lot of time to spend looking for errors. Exploding
early and often works well for me. You should experiment with different
approaches and see what works well for you.



This archive was generated by hypermail 2.0b3 on Fri May 09 2003 - 15:30:05 EDT