Click here to Skip to main content
15,912,756 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: goto statement Pin
PIEBALDconsult10-Nov-13 4:47
mvePIEBALDconsult10-Nov-13 4:47 
GeneralRe: goto statement Pin
altomaltes10-Nov-13 20:23
professionalaltomaltes10-Nov-13 20:23 
GeneralRe: goto statement Pin
PIEBALDconsult10-Nov-13 5:04
mvePIEBALDconsult10-Nov-13 5:04 
GeneralRe: goto statement Pin
CPallini10-Nov-13 6:13
mveCPallini10-Nov-13 6:13 
GeneralRe: goto statement Pin
  Forogar  10-Nov-13 6:23
professional  Forogar  10-Nov-13 6:23 
GeneralRe: goto statement Pin
CPallini10-Nov-13 6:30
mveCPallini10-Nov-13 6:30 
GeneralRe: goto statement Pin
Bill_Hallahan10-Nov-13 6:31
Bill_Hallahan10-Nov-13 6:31 
GeneralRe: goto statement Pin
  Forogar  10-Nov-13 6:51
professional  Forogar  10-Nov-13 6:51 
I prefer:
C#
// Some code here.  Entering a section with lots of error checking.
// Some code goes here that sets an error condition.
if (!error)
{
   // Some more code that sets an error condition.
   if (!error)
   {
      // Even more code that sets an error condition.
      if (!error)
      {
         // etc.
      }
   }
}
// The code continues here.

No "do...while" required.
This also has the advantage that excessive indenting reminds the programmer that they need to break the code out into method calls to simplify the layout. Once it gets past four or five indents this becomes obvious.
Better would be:
C#
// Some code here.  Entering a section with lots of error checking.
// Some code goes here that sets an error condition.
if (error)
{
   // Report error details here.
}
else
{
   // Some more code that sets an error condition.
   if (error)
   {
      // Report error details here.
   }
   else
   {
      // Even more code that sets an error condition.
      if (error)
      {
         // Report error details here.
      }
      else
      {
         // etc.
      }
   }
}
// The code continues here.

This way each error can be reported as necessary, perhaps with some cleanup or roll-back code.
- I would love to change the world, but they won’t give me the source code.

GeneralRe: goto statement Pin
Bill_Hallahan10-Nov-13 7:05
Bill_Hallahan10-Nov-13 7:05 
GeneralRe: goto statement Pin
Rob Grainger10-Nov-13 22:50
Rob Grainger10-Nov-13 22:50 
GeneralRe: goto statement Pin
Bill_Hallahan11-Nov-13 5:05
Bill_Hallahan11-Nov-13 5:05 
GeneralRe: goto statement Pin
Rob Grainger11-Nov-13 8:28
Rob Grainger11-Nov-13 8:28 
GeneralRe: goto statement Pin
Bill_Hallahan11-Nov-13 13:51
Bill_Hallahan11-Nov-13 13:51 
GeneralRe: goto statement Pin
Rob Grainger12-Nov-13 2:00
Rob Grainger12-Nov-13 2:00 
GeneralRe: goto statement Pin
Tarek Elqusi10-Nov-13 6:53
professionalTarek Elqusi10-Nov-13 6:53 
GeneralRe: goto statement Pin
Marc Clifton10-Nov-13 9:58
mvaMarc Clifton10-Nov-13 9:58 
GeneralRe: goto statement Pin
Joe Woodbury10-Nov-13 10:14
professionalJoe Woodbury10-Nov-13 10:14 
GeneralRe: goto statement Pin
Christian Graus10-Nov-13 12:01
protectorChristian Graus10-Nov-13 12:01 
GeneralRe: goto statement Pin
Member 1008817110-Nov-13 12:55
Member 1008817110-Nov-13 12:55 
GeneralRe: goto statement Pin
Stefan_Lang11-Nov-13 1:42
Stefan_Lang11-Nov-13 1:42 
GeneralRe: goto statement Pin
vl211-Nov-13 8:01
vl211-Nov-13 8:01 
GeneralRe: goto statement Pin
Stefan_Lang12-Nov-13 1:15
Stefan_Lang12-Nov-13 1:15 
GeneralRe: goto statement Pin
vl212-Nov-13 1:30
vl212-Nov-13 1:30 
GeneralRe: goto statement Pin
werinus12-Nov-13 1:34
werinus12-Nov-13 1:34 
GeneralRe: goto statement Pin
vl212-Nov-13 1:45
vl212-Nov-13 1:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.