Refactoring method with many conditional return statements
Posted
by MC.
on Stack Overflow
See other posts from Stack Overflow
or by MC.
Published on 2010-03-02T20:12:38Z
Indexed on
2010/06/16
0:22 UTC
Read the original article
Hit count: 579
Hi,
I have a method for validation that has many conditional statements. Basically it goes
If Check1 = false
return false
If Check2 = false
return false
etc
FxCop complains that the cyclomatic complexity is too high. I know that it is not best practice to have return statements in the middle of functions, but at the same time the only alternative I see is an ugly list of If-else statements. What is the best way to approach this?
Thanks in advance.
© Stack Overflow or respective owner