Hacker News new | ask | show | jobs
by DougBTX 5529 days ago
I'm not sure what you mean by exception driven development.

The original code was trying to express that e.NewItem should be a Customer. In all the following code, it is still an error for e.NewItem to not be a Customer. The question is what should happen when that error occurs.

There are three options discussed: 1) NullReferenceException, 2) Silent error, 3) InvalidCastException. Performance does not come into it, since if any of the error handling code paths get triggered, there is a bug which needs to be fixed. The claim in the article is that by throwing the right exception (InvalidCastException) it will be easier to track down the bug than if the wrong exception was thrown, or if the error was ignored.