How do you handle huge if-conditions?

Posted by Teifion on Stack Overflow See other posts from Stack Overflow or by Teifion
Published on 2008-08-08T16:45:58Z Indexed on 2010/05/09 12:08 UTC
Read the original article Hit count: 189

Filed under:
|

It's something that's bugged me in every language I've used, I have an if statement but the conditional part has so many checks that I have to split it over multiple lines, use a nested if statement or just accept that it's ugly and move on with my life.

Are there any other methods that you've found that might be of use to me and anybody else that's hit the same problem?

Example, all on one line:

if (var1 = true && var2 = true && var2 = true && var3 = true && var4 = true && var5 = true && var6 = true)
{

Example, multi-line:

if (var1 = true && var2 = true && var2 = true
 && var3 = true && var4 = true && var5 = true
 && var6 = true)
{

Example-nested:

if (var1 = true && var2 = true && var2 = true && var3 = true)
{
     if (var4 = true && var5 = true && var6 = true)
     {

© Stack Overflow or respective owner

Related posts about language-agnostic

Related posts about if