On Nov 7, 2005, at 4:32 AM, Robert Klemme wrote: > IMHO using int's as return values is as bad as using boolean return > values > in a language that has exceptions. Exceptions are a far more > elegant way > of handling errors and also often code will be shorter and cleaner. I tend to think there is a middle ground also. Bertrand Meyer has written a lot about the use of exceptions in programming. I tend towards his model where an exception is, well, exceptional. That is to say that an exception shouldn't be used to model an outcome that is *expected*. There is a nice side bar in Agile Web Development in Rails where David talks about Active Record and exceptions. He explains why: Person.find(5) raises an exception if the record is not found while Person.find(:first, :condition => "name = 'Dave'") returns an empty result if the record is not found. The difference is that in the first case, the assumption is that the record exists (otherwise I wouldn't have known to use 5 versus some other key). If the record doesn't exist then something bad or exceptional has happened. In the second example, we are trying to determine if the record exists and so the fact that it may not exist is entirely expected. In this case an exception is not warranted because the outcome "doesn't exist" is anticipated by the caller. Bertrand Meyer ties this all back to his Design by Contract philosophy. If the outcome is part of the contract then an exception is probably not needed. If the outcome violates the contract then the exception is probably desired. Gary Wright