Wednesday, April 28, 2010

Easier debugging thanks to lightweight methods

On this blog I had the opportunity to discuss about the advantages in respecting basic Code Metrics thresholds, such as having a method with low numbers of Lines of Code, low Cyclomatic Complexity, low Nesting Depth, low number of parameters, low number of variables etc...

But while doing intensive debugging today, I just realized another advantage in having lightweight methods: When a client reports a stack trace, with a typical let's say NullReferenceException, having a lightweight method that throw such exception de-facto limits the number of potential culprits references in the method. Ideally I can know exactly which reference in the method was null at run-time and provoked the exception. Btw, it is also efficient to investigate in the set of methods callers from the stack trace, to assert which reference weren't null at runtime and limit he number of culprits.

Read more: CodeBetter.com

Posted via email from jasper22's posterous