参数*反*异常使用 [英] Arguments *Against* Exception Use

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

问题描述

大家好,


我刚刚与最近加入的软件开发团队会面,因为他们正在创建人员一个中型项目

(可能所有这些都将用C ++编写)。根据我的经验和

读数,我来到这个小组被灌输使用异常处理错误

处理。这个小组的经验使他们相信

异常只应该用于严重的运行时错误需要程序的情况

终止主要是基于对性能影响的概念

例外情况令人望而却步。


除了Meyers书籍和我可靠的C ++常见问题解答副本外,我还在继续我的

基于多年经验的直觉。我是否过度灌输了使用

的例外情况?是否有一些警告我不听?

例外可以影响我的同事声称的表现吗?如果它们存在,我会听到一些反异常的想法。


谢谢!

Scott


-

从我的电子邮件地址中删除.nospam给我发邮件。

http://www.e-scott.net

Hi, all,

I just got out of a meeting with a team of software developers that I
recently joined as they are staffing to create a medium-sized project
(potentially all of which will be written in C++). From my experience and
readings, I''ve come to this group indoctrinated to use exceptions for error
handling. The experience in this group that leads them to believe that
exceptions should only be used where severe runtime errors require program
termination is mainly based on the notion that the performance impact of
exceptions is prohibitive.

Besides the Meyers books and my trusty copy of "C++ FAQs", I''m going on my
intuition based on years of experience. Am I over-indoctrinated in the use
of exceptions? Are there some warnings that I''m not heeding? Can
exceptions impact performance to the degree that my coworkers claim? I''d
like to hear some anti-exception thoughts, if they exist.

Thanks!
Scott

--
Remove .nospam from my e-mail address to mail me.

http://www.e-scott.net

推荐答案

* Scott Brady Drummonds:
* Scott Brady Drummonds:
全部,

我刚刚与我最近的软件开发团队会面加入,因为他们正在配备人员以创建一个中型项目
(可能所有这些都将用C ++编写)。根据我的经验和
读数,我来到这个小组进行灌输,使用异常处理错误。该小组的经验使他们相信,只有在严重的运行时错误需要程序终止的情况下才会使用异常主要是基于以下概念:
异常的性能影响是令人望而却步的。

除了迈耶斯的书籍和我可靠的C ++常见问题解答副本之外,我根据多年的经验继续我的直觉。我是否过度灌输了例外的使用?是否有一些警告我不听?
异常可以影响我的同事声称的表现吗?如果它们存在,我会想听一些反异常的想法。
Hi, all,

I just got out of a meeting with a team of software developers that I
recently joined as they are staffing to create a medium-sized project
(potentially all of which will be written in C++). From my experience and
readings, I''ve come to this group indoctrinated to use exceptions for error
handling. The experience in this group that leads them to believe that
exceptions should only be used where severe runtime errors require program
termination is mainly based on the notion that the performance impact of
exceptions is prohibitive.

Besides the Meyers books and my trusty copy of "C++ FAQs", I''m going on my
intuition based on years of experience. Am I over-indoctrinated in the use
of exceptions? Are there some warnings that I''m not heeding? Can
exceptions impact performance to the degree that my coworkers claim? I''d
like to hear some anti-exception thoughts, if they exist.




背景?


如果编写微控制器或操作系统内核:是的,C ++异常

可能是UnGood。


否则:否,C ++异常很好。


但不管上下文如何,如果问题确实在桌面上,那么一个合理的方法可以用来衡量典型的代码。要付出的代价:b $ b $衡量:完成正确运行代码所需的时间,所需时间

代码的一些修改,普通用法的执行时间。


我打赌那些软件开发人员认为原始指针和匈牙利表示法(不是提到存储库来复制代码片段!)也是很好的想法...... br />

-

答:因为它弄乱了人们通常阅读文字的顺序。

问:为什么会这样是坏事吗?

A:热门发布。

问:usenet和电子邮件中最烦人的是什么?



Context?

If coding for a micro-controller or, say, an OS kernel: yes, C++ exceptions
are probably UnGood.

Otherwise: no, C++ exceptions are Good.

But regardless of context, if the question is really on the table, then one
reasonable way to proceed could be to measure typical code. Things to
measure: time needed to complete correctly functioning code, time needed to do
some modification of the code, execution time in ordinary usage.

I bet those software developers think raw pointers and Hungarian notation (not
to mention a "repository" to copy code snippets from!) are nice ideas, too...

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?


" Scott Brady Drummonds" < SC ********************** @ intel.com>写在

消息新闻:cm ********** @ news01.intel.com ...
"Scott Brady Drummonds" <sc**********************@intel.com> wrote in
message news:cm**********@news01.intel.com...
我想要听一些反异常的想法,如果它们存在的话。
I''d like to hear some anti-exception thoughts, if they exist.




您可能想阅读Herb Sutter的文章名为何时以及如何使用

异常,发表在2004年8月的C / C ++用户期刊上。


如果您决定在项目中使用例外,那么专用于
$ b的部分Herb Sutter书中的例外C ++中的$ b例外将是

特别有用:)这本书有续集,应该是

也有帮助,但我没有'还没看过:

http:// www.gotw.ca/publications/index.htm


Ali



You may want to read Herb Sutter''s article named When and How to Use
Exceptions, in the August 2004 issue of the C/C++ Users Journal.

If you decide to use exceptions in the project, the section dedicated to
exceptions in the book Exceptional C++ by Herb Sutter will be
exceptionally useful :) There are sequels to this book, which should be
helpful too, but I haven''t read them yet:

http://www.gotw.ca/publications/index.htm

Ali


" Scott Brady Drummonds < SC ********************** @ intel.com>写在

消息新闻:cm ********** @ news01.intel.com ...
"Scott Brady Drummonds" <sc**********************@intel.com> wrote in
message news:cm**********@news01.intel.com...
全部,
<我刚刚与最近加入的软件开发团队会面,因为他们正在配备人员来创建一个中型项目
(可能所有这些都将用C ++编写) 。根据我的经验和
读数,我来到这个小组被灌输使用异常处理
错误。该小组的经验使他们相信,只有在严重的运行时错误需要程序终止的情况下才会使用异常主要是基于以下概念:
异常的性能影响是令人望而却步的。

除了迈耶斯的书籍和我可靠的C ++常见问题解答副本之外,我根据多年的经验继续我的直觉。我是否过度灌输了
使用例外情况?是否有一些警告我不听?
异常可以影响我的同事声称的表现吗?如果它们存在,我会想听到一些反异常的想法。

谢谢!
Scott

-
从我的电子邮件地址中删除.nospam给我发邮件。

http ://www.e-scott.net
Hi, all,

I just got out of a meeting with a team of software developers that I
recently joined as they are staffing to create a medium-sized project
(potentially all of which will be written in C++). From my experience and
readings, I''ve come to this group indoctrinated to use exceptions for
error
handling. The experience in this group that leads them to believe that
exceptions should only be used where severe runtime errors require program
termination is mainly based on the notion that the performance impact of
exceptions is prohibitive.

Besides the Meyers books and my trusty copy of "C++ FAQs", I''m going on my
intuition based on years of experience. Am I over-indoctrinated in the
use
of exceptions? Are there some warnings that I''m not heeding? Can
exceptions impact performance to the degree that my coworkers claim? I''d
like to hear some anti-exception thoughts, if they exist.

Thanks!
Scott

--
Remove .nospam from my e-mail address to mail me.

http://www.e-scott.net




我永远无法弄清楚异常的使用如何导致如此大的运行时间

错误。如果你正确地使用它们作为错误处理程序而不是控制它们的b $ b结构,它们就不会经常被调用以运行很长的执行时间。

如果你避免异常规范(这基本上没用了

无论如何)他们根本没有太多开销。


-

Cy
http://home.rochester.rr.com/cyhome/


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

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