benchmarking - Which method for handling conditions inside a function would be the most practical? -
what's fastest, safest, , practical way of handling conditions inside function condition match must passed before function can proceed code @ all? below have function returns on condition failure, , function checks condition success:
function x() { if ( !condition ) return; [code] }
or
function y() { if ( condition ) { [code] } }
mccabe's cyclomatic complexity punishes functions more 1 return statement. guess provide formalism supports structured programming (one entry point each function/"goto statement considered harmful") taken extreme, i.e. 1 exit point each function.
reducing number of return statements in function reduces number of break-points insert in debugging situation final values of function local variables inspected.
if development method involves frequent use of debugger argue using y()
approach.
Comments
Post a Comment