Optimize The Success Path

Too often when coding we focus on writing code to detect errors before executing the main 'meat' of the function. Someone who has passed in all the correct parameters will have to pay the performance penalty of all the checks.

Instead, we should write code that runs as fast as possible for the correct cases, even if it means that we'll run slower by a magnitude in the error cases. Optimize the success path. Let the sinners pay.

Exceptions fit in nicely with this school of thought. Error codes don't.

See RulesOfOptimization


EditText of this page (last edited June 3, 2008) or FindPage with title or text search