<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Google Forbids Use of Exception in C++</title>
	<atom:link href="http://fsfoundry.org/codefreak/2008/07/06/google-forbids-use-of-exception-in-cpp/feed/" rel="self" type="application/rss+xml" />
	<link>http://fsfoundry.org/codefreak/2008/07/06/google-forbids-use-of-exception-in-cpp/</link>
	<description>Weblog of a lively geek.</description>
	<lastBuildDate>Thu, 04 Mar 2010 10:35:11 -0800</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: exception使用的時機 &#171; Jay</title>
		<link>http://fsfoundry.org/codefreak/2008/07/06/google-forbids-use-of-exception-in-cpp/comment-page-1/#comment-7796</link>
		<dc:creator>exception使用的時機 &#171; Jay</dc:creator>
		<pubDate>Wed, 01 Jul 2009 08:43:12 +0000</pubDate>
		<guid isPermaLink="false">http://fsfoundry.org/codefreak/2008/07/06/google-gorbids-use-of-exception-in-cpp/#comment-7796</guid>
		<description>[...] Google Forbids Use of Exception in C++ [...]</description>
		<content:encoded><![CDATA[<p>[...] Google Forbids Use of Exception in C++ [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: augustinus</title>
		<link>http://fsfoundry.org/codefreak/2008/07/06/google-forbids-use-of-exception-in-cpp/comment-page-1/#comment-4530</link>
		<dc:creator>augustinus</dc:creator>
		<pubDate>Thu, 17 Jul 2008 11:15:11 +0000</pubDate>
		<guid isPermaLink="false">http://fsfoundry.org/codefreak/2008/07/06/google-gorbids-use-of-exception-in-cpp/#comment-4530</guid>
		<description>看起來其實好像也沒那麼嚴重？

Google 列出的 Cons (of using exception) 第一條和 Joel 的 http://www.joelonsoftware.com/items/2003/10/13.html 差不多意思，而且您先前的文章也包含了相關的部分。

正因為那需要專業程度，換句話說就是犯錯的機會增加了，即使是最優秀的工程師都有可能在狀況差的時候對這些事有所疏忽。於是我的推測是，正如 Google 在文件上寫的，它不想承擔這類型的成本。

另外我也猜測，Google 或許用 code review 和 unit test 從外部來取代某些語言內部機制提供的能力。</description>
		<content:encoded><![CDATA[<p>看起來其實好像也沒那麼嚴重？</p>
<p>Google 列出的 Cons (of using exception) 第一條和 Joel 的 <a href="http://www.joelonsoftware.com/items/2003/10/13.html" rel="nofollow">http://www.joelonsoftware.com/items/2003/10/13.html</a> 差不多意思，而且您先前的文章也包含了相關的部分。</p>
<p>正因為那需要專業程度，換句話說就是犯錯的機會增加了，即使是最優秀的工程師都有可能在狀況差的時候對這些事有所疏忽。於是我的推測是，正如 Google 在文件上寫的，它不想承擔這類型的成本。</p>
<p>另外我也猜測，Google 或許用 code review 和 unit test 從外部來取代某些語言內部機制提供的能力。</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: eXile</title>
		<link>http://fsfoundry.org/codefreak/2008/07/06/google-forbids-use-of-exception-in-cpp/comment-page-1/#comment-4526</link>
		<dc:creator>eXile</dc:creator>
		<pubDate>Tue, 15 Jul 2008 15:53:22 +0000</pubDate>
		<guid isPermaLink="false">http://fsfoundry.org/codefreak/2008/07/06/google-gorbids-use-of-exception-in-cpp/#comment-4526</guid>
		<description>呵呵， 我没有表达清楚，我的意思是，像string这种基础设施可以使用异常，但在业务比较复杂的应用开发中，还是不要使用异常为好。</description>
		<content:encoded><![CDATA[<p>呵呵， 我没有表达清楚，我的意思是，像string这种基础设施可以使用异常，但在业务比较复杂的应用开发中，还是不要使用异常为好。</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: fr3@K</title>
		<link>http://fsfoundry.org/codefreak/2008/07/06/google-forbids-use-of-exception-in-cpp/comment-page-1/#comment-4516</link>
		<dc:creator>fr3@K</dc:creator>
		<pubDate>Fri, 11 Jul 2008 05:26:58 +0000</pubDate>
		<guid isPermaLink="false">http://fsfoundry.org/codefreak/2008/07/06/google-gorbids-use-of-exception-in-cpp/#comment-4516</guid>
		<description>的確, exception safety 不是容易達成的, 我也寫過一些相關的文字 (&lt;a href=&quot;http://fsfoundry.org/codefreak/2008/04/29/strong-guarantee-using-transaction/&quot; title=&quot;Strong Guarantee using Transaction&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;, &lt;a href=&quot;http://fsfoundry.org/codefreak/2007/08/19/resource-management-using-auto-ptr-intro/&quot; title=&quot;Resource Management using auto_ptr - Intro&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt; and &lt;a href=&quot;http://fsfoundry.org/codefreak/2007/09/06/resource-management-using-auto_ptr-not-always-so-simple/&quot; title=&quot;Resource Management using auto_ptr - Not Always So Simple&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;). 小弟潛見, 我認為那正是專業與業餘 C++ 程序員的區別之一.

你的最後一句話我有不一樣的看法:
&lt;blockquote&gt;像String这种属于基础库的设施，而对于普通的应用开发，如果没有特别的理由，都不应该使用异常。&lt;/blockquote&gt;

我的看法是愈是像 String 這種基礎設施, 常常, 愈有機會正確地使用 exception. 因為 call stack 的上上下下大家都在使用, 但能處理錯誤的人卻常不在附近. 回到我在這篇文字中舉的例子, 除了靠近最上層的程序可能有足夠的 knowledge 能 recover 或是對使用者提示錯誤狀況之外, 中間的 code 能拿 String 記憶體請求失敗怎麼辦?

換一個對象來看, 若是針對較特殊應用的&quot;零件&quot;, 像是設置檔的讀寫, 由於被使用/參考的範圍較小, 很容易在接近錯誤出現的地方就能對錯誤加以處理. 例如在讀設置檔時找不到某個欄位的資料 (例如讀不到上一次關閉時視窗的座標) 時, 使用 exception 來回報錯誤就很可能是小題大作了.

我絕對不是在鼓吹 exception 有多好, 即便是用在 String 身上. 例如在這樣的 function 就不適合:
&lt;pre&gt;
&lt;strong&gt;some_integral_type&lt;/strong&gt; String::FindSubString(const String&amp; sub);
&lt;/pre&gt;
大多數的情況下, 字符串的內容是動態的 (外部輸入的), 找不到一段 sub-string 是執行時期的 input validation 錯誤, 以 error code 方式回報可能更為恰當.</description>
		<content:encoded><![CDATA[<p>的確, exception safety 不是容易達成的, 我也寫過一些相關的文字 (<a href="http://fsfoundry.org/codefreak/2008/04/29/strong-guarantee-using-transaction/" title="Strong Guarantee using Transaction" rel="nofollow">here</a>, <a href="http://fsfoundry.org/codefreak/2007/08/19/resource-management-using-auto-ptr-intro/" title="Resource Management using auto_ptr - Intro" rel="nofollow">here</a> and <a href="http://fsfoundry.org/codefreak/2007/09/06/resource-management-using-auto_ptr-not-always-so-simple/" title="Resource Management using auto_ptr - Not Always So Simple" rel="nofollow">here</a>). 小弟潛見, 我認為那正是專業與業餘 C++ 程序員的區別之一.</p>
<p>你的最後一句話我有不一樣的看法:</p>
<blockquote><p>像String这种属于基础库的设施，而对于普通的应用开发，如果没有特别的理由，都不应该使用异常。</p></blockquote>
<p>我的看法是愈是像 String 這種基礎設施, 常常, 愈有機會正確地使用 exception. 因為 call stack 的上上下下大家都在使用, 但能處理錯誤的人卻常不在附近. 回到我在這篇文字中舉的例子, 除了靠近最上層的程序可能有足夠的 knowledge 能 recover 或是對使用者提示錯誤狀況之外, 中間的 code 能拿 String 記憶體請求失敗怎麼辦?</p>
<p>換一個對象來看, 若是針對較特殊應用的&#8221;零件&#8221;, 像是設置檔的讀寫, 由於被使用/參考的範圍較小, 很容易在接近錯誤出現的地方就能對錯誤加以處理. 例如在讀設置檔時找不到某個欄位的資料 (例如讀不到上一次關閉時視窗的座標) 時, 使用 exception 來回報錯誤就很可能是小題大作了.</p>
<p>我絕對不是在鼓吹 exception 有多好, 即便是用在 String 身上. 例如在這樣的 function 就不適合:</p>
<pre>
<strong>some_integral_type</strong> String::FindSubString(const String&#038; sub);
</pre>
<p>大多數的情況下, 字符串的內容是動態的 (外部輸入的), 找不到一段 sub-string 是執行時期的 input validation 錯誤, 以 error code 方式回報可能更為恰當.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: eXile</title>
		<link>http://fsfoundry.org/codefreak/2008/07/06/google-forbids-use-of-exception-in-cpp/comment-page-1/#comment-4515</link>
		<dc:creator>eXile</dc:creator>
		<pubDate>Thu, 10 Jul 2008 14:16:44 +0000</pubDate>
		<guid isPermaLink="false">http://fsfoundry.org/codefreak/2008/07/06/google-gorbids-use-of-exception-in-cpp/#comment-4515</guid>
		<description>基本赞同。应该有限制的使用异常。
google的风格必然导致两阶段构造对象法。
但是编写异常安全的代码比想象的要难一些。
像String这种属于基础库的设施，而对于普通的应用开发，如果没有特别的理由，都不应该使用异常。</description>
		<content:encoded><![CDATA[<p>基本赞同。应该有限制的使用异常。<br />
google的风格必然导致两阶段构造对象法。<br />
但是编写异常安全的代码比想象的要难一些。<br />
像String这种属于基础库的设施，而对于普通的应用开发，如果没有特别的理由，都不应该使用异常。</p>
]]></content:encoded>
	</item>
</channel>
</rss>
