<?xml version="1.0" standalone="yes"?>
<?xml-stylesheet type="text/xsl" href="css/rss.xslt"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>张逸·捷道咨询-泛型的一点遗憾</title><link>http://www.agiledon.com/post/2009/02/Generic-Defect.html</link><generator>RainbowSoft Studio Z-Blog 1.8 Arwen Build 81206</generator><language>zh-CN</language><pubDate>Sat, 14 Feb 2009 09:48:21 +0800</pubDate><item><title>Re:泛型的一点遗憾</title><author>nick@nodomain.com (NickWang)</author><link>http://www.agiledon.com/post/2009/02/Generic-Defect.html#cmt27</link><pubDate>Wed, 04 Mar 2009 22:52:43 +0800</pubDate><guid>http://www.agiledon.com/post/2009/02/Generic-Defect.html#cmt27</guid><description><![CDATA[如果构造一个所有自定义异常的基类，并把LogService.Error(message);这一句加到基类的构造函数中，我觉得就可以解决这个问题了。<br/><br/>]]></description></item><item><title>Re:泛型的一点遗憾</title><author>opend@live.com (Opend)</author><link>http://www.agiledon.com/post/2009/02/Generic-Defect.html#cmt26</link><pubDate>Wed, 04 Mar 2009 19:00:31 +0800</pubDate><guid>http://www.agiledon.com/post/2009/02/Generic-Defect.html#cmt26</guid><description><![CDATA[代码量变化应该不大，只传参数的话，要声明具体类型，传实例的可以交给编译器判断，我也感觉，你的ThrowHelper本身就有工厂的作用，这样做可能与现有模式不一致，之前想过用静态类解决非这个，结果绕来绕去还是回到泛型构造函数上来了。]]></description></item><item><title>Re:泛型的一点遗憾</title><author>opend@live.com (opend)</author><link>http://www.agiledon.com/post/2009/02/Generic-Defect.html#cmt21</link><pubDate>Wed, 04 Mar 2009 05:08:01 +0800</pubDate><guid>http://www.agiledon.com/post/2009/02/Generic-Defect.html#cmt21</guid><description><![CDATA[这样做应该可行<br/>public static void ThrowCustomerException&lt;TCustomException&gt;(TCustomException customException) where TCustomException:ApplicationException<br/>{<br/>            //Some Methods<br/>            LogService.Error(customException.Message);<br/>            throw customException;<br/>}<br/>调用时，传入一个自定义异常的实例。而不是在方法体内实例化。耦合性可能高些。<blockquote><div class="quote quote3"><div class="quote-title">麒麟.NET 于 2009-3-4 9:54:55 回复</div>确实可行，但是ThrowHelper的职责就是生成Exception实例，并且抛出，不仅仅局限于日志记录之类的。如果在调用ThrowHelper的方法之前要实例化Exception，客户端代码没有减少，不能体现设计的初衷。</div></blockquote>]]></description></item><item><title>Re:泛型的一点遗憾</title><author> (麒麟.NET)</author><link>http://www.agiledon.com/post/2009/02/Generic-Defect.html#cmt13</link><pubDate>Tue, 03 Mar 2009 17:24:18 +0800</pubDate><guid>http://www.agiledon.com/post/2009/02/Generic-Defect.html#cmt13</guid><description><![CDATA[学习了！居然和我遇到的问题一样，而且居然类名都是一模一样的，呵呵。<br/>因为Exception.Message是只读的，还不能在代码里设置。郁闷了很长时间。谢谢！]]></description></item></channel></rss>
