Hi,
I would like to ask peoples opinion of the "goto" statement in C#.
I have always been taught NOT to use this statement in OO code (first OO
language I learned was C++ about 8 years ago) as it creates "saghettii
code"
I would have throught that using a function to "jump" to other code is far
better than a "goto" statement.
is this the general opinion of people or have a missed a good use of the
goto statement.
any comments appreciated.
cheers
martin.Though I currently use vb it's probably been 20 years since I last used a
goto...having long ago been preached to about the evils of goto. Not only
does it make code more difficult to follow the more you use it but also its
need, to jump to a specific memory location for code, is somewhat dated (but
that's just my opinion).
"Martin" <martin_NO_SPAM_WANTED@.martinz.co.nz> wrote in message
news:u28FVGfRFHA.2228@.TK2MSFTNGP12.phx.gbl...
> Hi,
> I would like to ask peoples opinion of the "goto" statement in C#.
> I have always been taught NOT to use this statement in OO code (first OO
> language I learned was C++ about 8 years ago) as it creates "saghettii
> code"
> I would have throught that using a function to "jump" to other code is far
> better than a "goto" statement.
> is this the general opinion of people or have a missed a good use of the
> goto statement.
> any comments appreciated.
> cheers
> martin.
>
>
>
Never use Goto.
There is always a better way to approach the problem, such as function
calls, nesting code blocks, etc.
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"Martin" <martin_NO_SPAM_WANTED@.martinz.co.nz> wrote in message
news:u28FVGfRFHA.2228@.TK2MSFTNGP12.phx.gbl...
> Hi,
> I would like to ask peoples opinion of the "goto" statement in C#.
> I have always been taught NOT to use this statement in OO code (first OO
> language I learned was C++ about 8 years ago) as it creates "saghettii
> code"
> I would have throught that using a function to "jump" to other code is far
> better than a "goto" statement.
> is this the general opinion of people or have a missed a good use of the
> goto statement.
> any comments appreciated.
> cheers
> martin.
>
>
>
GOTO was originally invented to jump over code.
10 if age < 18 then goto 40
20 ...
30 ...
40 (some more code here)
Once code segments were invented it made GOTO obsolete. I have no idea
why people still use GOTO in their code, and absolutely no idea why
people add GOTO to their languages.
Pete
====
ECO Modeler, Audio compression components, DIB graphics controls,
FastStrings
http://www.droopyeyes.com
Read or write articles on just about anything
http://www.HowToDoThings.com
My blog
http://blogs.slcdug.org/petermorris/
Thanks All for your comments.
cheers
martin.
"Peter Morris [Droopy eyes software]" <pete@.not.this.or.this.droopyeyes.com>
wrote in message news:eP60WSrRFHA.1348@.TK2MSFTNGP15.phx.gbl...
> GOTO was originally invented to jump over code.
> 10 if age < 18 then goto 40
> 20 ...
> 30 ...
> 40 (some more code here)
> Once code segments were invented it made GOTO obsolete. I have no idea
> why people still use GOTO in their code, and absolutely no idea why people
> add GOTO to their languages.
> --
> Pete
> ====
> ECO Modeler, Audio compression components, DIB graphics controls,
> FastStrings
> http://www.droopyeyes.com
> Read or write articles on just about anything
> http://www.HowToDoThings.com
> My blog
> http://blogs.slcdug.org/petermorris/
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment