views:

190

answers:

7

I cant for the life of me remember what the word is. It's when you ???? several if/else/for/while/usings inside each other.


   bool isTrue = true, isFalse = true, HasForgottenWord = true;

   if( isTrue )
   {
      if( isFalse )
      {
          if( HasForgottenWord )
          {
              Console.WriteLine("Ask on StackOverflow.com - kthx bye");
          }
      }
   }

Edit: Thank you all!

A: 

It is called: bad

Noon Silk
Are you implying that every time we have a nested code block we should seek an alternative? He asked a simple question, please try to be helpful.
JoshJordan
I have written (C++) code where I have way too many nested statements, the reasoning was to have a single point of exit. After that, I don't nest as much. Instead of if(success), I practice if(!success) and handle it [the error] there.
CS
JoshJordan - I consider it helpful to learn the good and the bad way to do things; don't you agree?
Noon Silk
Absolutely. Unfortunately, you side stepped the question *and* made a strange implication that nested code blocks are avoidable in production code.
JoshJordan
silky: Your answer pretty much says that nesting is bad - I think what you mean is that nesting too deeply is bad. Am I right?
Blorgbeard
Speaking of too much nesting: view source on http://www.fujinonbinos.com/
Blorgbeard
+14  A: 

It's called nesting

Glen
+4  A: 

Its called "nesting" them :)

JoshJordan
+4  A: 

nested maybe what you're looking for.

Mehmet Aras
+4  A: 

I think nesting might be what he's looking for...

Dorjan
+1  A: 

... right: It's called nesting and deep nesting is generally considered a code smell.

Loop block nesting can be reduced by the Linus-Torvalds-Trick (see Mono Coding Guidelines).

The Chairman
why did this get a downvote? it answers the question and provides additional information.
Maslow
+3  A: 

It is called as nesting loops

Senthil Kumar Bhaskaran