使用GOTO [英] Using GOTO

查看:76
本文介绍了使用GOTO的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



在.NET应用程序中使用GOTO是不错的做法?


请指教。


谢谢,Kartic

Hi,
Is it good practice using GOTO in .NET application?

Please advice.

Thanks, Kartic

推荐答案

我不是很虔诚,虽然我没有一个GOTO在
在我的项目中
50,000行代码。这不是必要的。但是,如果您觉得需要,请作为我的客人;)

" Kartic" <千克**** @ csystemssoftware.com>在消息中写道

news:uC ************** @ TK2MSFTNGP12.phx.gbl ...
I''m not religious about it, although I don''t have a single GOTO in over
50,000 lines of code in my project. It isn''t neccessary. But if you feel
the need, be my guest ;)
"Kartic" <kg****@csystemssoftware.com> wrote in message
news:uC**************@TK2MSFTNGP12.phx.gbl...
在.NET应用程序中使用GOTO是不错的做法?

请指教。

谢谢,Kartic
Hi,
Is it good practice using GOTO in .NET application?

Please advice.

Thanks, Kartic



嗨Kartic,


这是严重的还是你想在这个新闻组中建立一个长线程。


答案是否定的。


Cor
Hi Kartic,

Is this serious or do you want to build a long thread in this newsgroup.

The answer is No.

Cor


Kartic:


有一个很少有情况下Goto可能是最好的解决方案,比如在你要模拟跌倒的

开关语句中。然而,那些

的情况确实很罕见,我可以算在他手上。 Goto真正的问题是人们过度使用它们并将它们用作slopppy

的快捷方式。和Robin一样,我认为在大约6万行代码中,我不认为

我曾经需要使用一个,而不愿意。我的例子

Fall-through主要与C#有关,只涉及switch语句。


基本上,答案是否定,不要用它。如果你完全确定使用GoTo是最有效的方法,那么请继续,但是

尽可能限制它的使用并制作确定你有一个非常引人注目的

使用它的理由。如果你的程序在罕见的场景中使用它超过一次或两次,那么你已经过度使用了它。


我也不信任它,我只是没有看到它的需要......

我已经看到它造成的伤害远远超过它的好处。

Kartic <千克**** @ csystemssoftware.com>在消息中写道

news:uC ************** @ TK2MSFTNGP12.phx.gbl ...
Kartic:

There are a few situations where Goto may be the best solution, like in a
switch statement where you want to simulate fall-through. However, those
situations are Rare indeed and I can count them on my hand. The real
problem with Goto is that people overuse them and use them as slopppy
shortcuts. Like Robin, I think in about 60,000 lines of code, I don''t think
I''ve ever needed to use one, and prefer not to. And my examples of
Fall-through is related to C# mainly and only deals with switch statements.

Basically, the answer is No, don''t use it. If you are absolutely sure that
using GoTo is the most effecitve way to do something, then go ahead, but
limit it''s use as much as possible and make sure you have a very compelling
reason to use it. And if your program uses it more than once or twice in
rare occassions, you are already overusing it.

I''m not religious about it either, I just don''t see much of a need for it...
and I''ve seen a lot more damage done with it than good come from it.
"Kartic" <kg****@csystemssoftware.com> wrote in message
news:uC**************@TK2MSFTNGP12.phx.gbl...
在.NET应用程序中使用GOTO是不错的做法?

请指教。

谢谢,Kartic
Hi,
Is it good practice using GOTO in .NET application?

Please advice.

Thanks, Kartic



这篇关于使用GOTO的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆