<?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: Warning: Using the IDataErrorInfo feature in an Asp.net MVC application should be considered a Worst Practice.</title>
	<atom:link href="http://lostechies.com/erichexter/2009/01/31/using-idataerrorinfo-in-an-asp-net-mvc-application-should-be-considered-worst-practice/feed/" rel="self" type="application/rss+xml" />
	<link>http://lostechies.com/erichexter/2009/01/31/using-idataerrorinfo-in-an-asp-net-mvc-application-should-be-considered-worst-practice/</link>
	<description></description>
	<lastBuildDate>Thu, 16 May 2013 09:01:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4.2</generator>
	<item>
		<title>By: Rob</title>
		<link>http://lostechies.com/erichexter/2009/01/31/using-idataerrorinfo-in-an-asp-net-mvc-application-should-be-considered-worst-practice/#comment-57</link>
		<dc:creator>Rob</dc:creator>
		<pubDate>Tue, 03 Feb 2009 17:39:51 +0000</pubDate>
		<guid isPermaLink="false">/blogs/hex/archive/2009/01/31/using-idataerrorinfo-in-an-asp-net-mvc-application-should-be-considered-worst-practice.aspx#comment-57</guid>
		<description>@bogardj

Care to post an example (or a link to one) of how you use your OperationResult and how it allows you to compose operations much better?     

I&#039;m pretty leery of 3rd party frameworks that don&#039;t tell me what exceptions they throw, and if I have to use one that doesn&#039;t divulge that information, I&#039;ll wrap its API to exert some control over what the rest of my application has to deal with.  

If I or my team wrote the framework (which is usually the case for the application domain model), we know what exceptions we&#039;re going to get.</description>
		<content:encoded><![CDATA[<p>@bogardj</p>
<p>Care to post an example (or a link to one) of how you use your OperationResult and how it allows you to compose operations much better?     </p>
<p>I&#8217;m pretty leery of 3rd party frameworks that don&#8217;t tell me what exceptions they throw, and if I have to use one that doesn&#8217;t divulge that information, I&#8217;ll wrap its API to exert some control over what the rest of my application has to deal with.  </p>
<p>If I or my team wrote the framework (which is usually the case for the application domain model), we know what exceptions we&#8217;re going to get.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bogardj</title>
		<link>http://lostechies.com/erichexter/2009/01/31/using-idataerrorinfo-in-an-asp-net-mvc-application-should-be-considered-worst-practice/#comment-56</link>
		<dc:creator>bogardj</dc:creator>
		<pubDate>Tue, 03 Feb 2009 17:10:43 +0000</pubDate>
		<guid isPermaLink="false">/blogs/hex/archive/2009/01/31/using-idataerrorinfo-in-an-asp-net-mvc-application-should-be-considered-worst-practice.aspx#comment-56</guid>
		<description>@Rob

Pssh!!! What do those guys know.

I like an &quot;OperationResult&quot; object, with Success and Errors as attributes. It lets me compose operations much better, and I don&#039;t have to resort to an IsValid.

Exceptions are annoying as control flow logic simply because they are neither obvious nor discoverable as users of a framework or API.  If something fails and I need to take action, tell me directly.  There is nothing in C# that allows me to know what exceptions &quot;might&quot; get thrown, so I can handle them appropriately.</description>
		<content:encoded><![CDATA[<p>@Rob</p>
<p>Pssh!!! What do those guys know.</p>
<p>I like an &#8220;OperationResult&#8221; object, with Success and Errors as attributes. It lets me compose operations much better, and I don&#8217;t have to resort to an IsValid.</p>
<p>Exceptions are annoying as control flow logic simply because they are neither obvious nor discoverable as users of a framework or API.  If something fails and I need to take action, tell me directly.  There is nothing in C# that allows me to know what exceptions &#8220;might&#8221; get thrown, so I can handle them appropriately.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rob</title>
		<link>http://lostechies.com/erichexter/2009/01/31/using-idataerrorinfo-in-an-asp-net-mvc-application-should-be-considered-worst-practice/#comment-55</link>
		<dc:creator>Rob</dc:creator>
		<pubDate>Tue, 03 Feb 2009 15:44:58 +0000</pubDate>
		<guid isPermaLink="false">/blogs/hex/archive/2009/01/31/using-idataerrorinfo-in-an-asp-net-mvc-application-should-be-considered-worst-practice.aspx#comment-55</guid>
		<description>@steve

I think the idea that exceptions should be reserved for &quot;exceptional&quot; circumstances is a vestige of the original guidance for using exceptions in C++ (as is the notion that using exceptions incurs a large performance penalty).  I believe that even in the C++ world, that guidance is no longer as absolute as it once was.

@bogardj

Actually, using exceptions to separate the concerns of error handling and main logic flow is a very good choice.  For a nice exposition on that take a look at Robert Martin&#039;s Clean Code and the section on Error Handling that Michael Feathers wrote.

Additionally, many would consider the use of an IsValid method on domain objects to be a poor practice.  The argument here is that domain objects should not be allowed to have an invalid state (i.e., have their invarients violated) at any point in time.  </description>
		<content:encoded><![CDATA[<p>@steve</p>
<p>I think the idea that exceptions should be reserved for &#8220;exceptional&#8221; circumstances is a vestige of the original guidance for using exceptions in C++ (as is the notion that using exceptions incurs a large performance penalty).  I believe that even in the C++ world, that guidance is no longer as absolute as it once was.</p>
<p>@bogardj</p>
<p>Actually, using exceptions to separate the concerns of error handling and main logic flow is a very good choice.  For a nice exposition on that take a look at Robert Martin&#8217;s Clean Code and the section on Error Handling that Michael Feathers wrote.</p>
<p>Additionally, many would consider the use of an IsValid method on domain objects to be a poor practice.  The argument here is that domain objects should not be allowed to have an invalid state (i.e., have their invarients violated) at any point in time.  </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bogardj</title>
		<link>http://lostechies.com/erichexter/2009/01/31/using-idataerrorinfo-in-an-asp-net-mvc-application-should-be-considered-worst-practice/#comment-54</link>
		<dc:creator>bogardj</dc:creator>
		<pubDate>Tue, 03 Feb 2009 14:22:12 +0000</pubDate>
		<guid isPermaLink="false">/blogs/hex/archive/2009/01/31/using-idataerrorinfo-in-an-asp-net-mvc-application-should-be-considered-worst-practice.aspx#comment-54</guid>
		<description>@Steve

It&#039;s just that exceptions as _control flow_ logic are a very poor choice.  It&#039;s like the old On Error Resume Next in VB6.  There are easier ways to indicate that an operation failed, and provide better options for consumers of APIs, than throwing an exception.</description>
		<content:encoded><![CDATA[<p>@Steve</p>
<p>It&#8217;s just that exceptions as _control flow_ logic are a very poor choice.  It&#8217;s like the old On Error Resume Next in VB6.  There are easier ways to indicate that an operation failed, and provide better options for consumers of APIs, than throwing an exception.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Steve Sanderson</title>
		<link>http://lostechies.com/erichexter/2009/01/31/using-idataerrorinfo-in-an-asp-net-mvc-application-should-be-considered-worst-practice/#comment-53</link>
		<dc:creator>Steve Sanderson</dc:creator>
		<pubDate>Tue, 03 Feb 2009 13:23:07 +0000</pubDate>
		<guid isPermaLink="false">/blogs/hex/archive/2009/01/31/using-idataerrorinfo-in-an-asp-net-mvc-application-should-be-considered-worst-practice.aspx#comment-53</guid>
		<description>@Karthik
&gt; Exceptions are pretty terrible for performance. If you do a simple test with Timers...

I have done exactly that and found that performance is absolutely fine. Did you? As long as you don&#039;t have a debugger attached, you can easily accommodate 10,000 - 100,000 exceptions per second, so setting up some logic that is likely to cause at most a few exceptions per second in total can&#039;t be rejected on performance grounds.

@various commenters
Who came up with the idea that exceptions should be reserved for &quot;exceptional&quot; circumstances, and what is exceptional anyway? The .NET framework class libraries establish a clear pattern for the semantics of an exception. In .NET, an exception means &quot;this method could not complete the operation that its name describes&quot; and that is why they&#039;re always used to signal an incomplete or failed operation (and why we don&#039;t use Win32-style return codes).

I&#039;m not saying that IDataErrorInfo is great (I would certainly change it in a couple of ways if I had the chance) but rather trying to understand why people don&#039;t want to use exceptions even for scenarios that match their intended use.</description>
		<content:encoded><![CDATA[<p>@Karthik<br />
> Exceptions are pretty terrible for performance. If you do a simple test with Timers&#8230;</p>
<p>I have done exactly that and found that performance is absolutely fine. Did you? As long as you don&#8217;t have a debugger attached, you can easily accommodate 10,000 &#8211; 100,000 exceptions per second, so setting up some logic that is likely to cause at most a few exceptions per second in total can&#8217;t be rejected on performance grounds.</p>
<p>@various commenters<br />
Who came up with the idea that exceptions should be reserved for &#8220;exceptional&#8221; circumstances, and what is exceptional anyway? The .NET framework class libraries establish a clear pattern for the semantics of an exception. In .NET, an exception means &#8220;this method could not complete the operation that its name describes&#8221; and that is why they&#8217;re always used to signal an incomplete or failed operation (and why we don&#8217;t use Win32-style return codes).</p>
<p>I&#8217;m not saying that IDataErrorInfo is great (I would certainly change it in a couple of ways if I had the chance) but rather trying to understand why people don&#8217;t want to use exceptions even for scenarios that match their intended use.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nathan Stott</title>
		<link>http://lostechies.com/erichexter/2009/01/31/using-idataerrorinfo-in-an-asp-net-mvc-application-should-be-considered-worst-practice/#comment-52</link>
		<dc:creator>Nathan Stott</dc:creator>
		<pubDate>Mon, 02 Feb 2009 17:18:34 +0000</pubDate>
		<guid isPermaLink="false">/blogs/hex/archive/2009/01/31/using-idataerrorinfo-in-an-asp-net-mvc-application-should-be-considered-worst-practice.aspx#comment-52</guid>
		<description>If you actually run a profile, exceptions may eat a lot of resources in debug mode, but in release mode they are insignificant.

Also, it is possible to use the IDataErrorInfo without using UpdateModel and having it throw an exception.  I am using parameter bound models as in your second example with IDataErrorInfo and it doesn&#039;t throw an exception on me if there are errors.  It simply sets ModelState.IsValid to false.</description>
		<content:encoded><![CDATA[<p>If you actually run a profile, exceptions may eat a lot of resources in debug mode, but in release mode they are insignificant.</p>
<p>Also, it is possible to use the IDataErrorInfo without using UpdateModel and having it throw an exception.  I am using parameter bound models as in your second example with IDataErrorInfo and it doesn&#8217;t throw an exception on me if there are errors.  It simply sets ModelState.IsValid to false.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Karthik Hariharan</title>
		<link>http://lostechies.com/erichexter/2009/01/31/using-idataerrorinfo-in-an-asp-net-mvc-application-should-be-considered-worst-practice/#comment-51</link>
		<dc:creator>Karthik Hariharan</dc:creator>
		<pubDate>Mon, 02 Feb 2009 16:37:49 +0000</pubDate>
		<guid isPermaLink="false">/blogs/hex/archive/2009/01/31/using-idataerrorinfo-in-an-asp-net-mvc-application-should-be-considered-worst-practice.aspx#comment-51</guid>
		<description>Exceptions are pretty terrible for performance.  If you do a simple test with Timers to see how costly they are, you will quickly move away from putting them in commonly executed code.  If you throw a lot of exceptions based on normal user input, you will be killing the performance of your site unnecessarily.</description>
		<content:encoded><![CDATA[<p>Exceptions are pretty terrible for performance.  If you do a simple test with Timers to see how costly they are, you will quickly move away from putting them in commonly executed code.  If you throw a lot of exceptions based on normal user input, you will be killing the performance of your site unnecessarily.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lee Campbell</title>
		<link>http://lostechies.com/erichexter/2009/01/31/using-idataerrorinfo-in-an-asp-net-mvc-application-should-be-considered-worst-practice/#comment-50</link>
		<dc:creator>Lee Campbell</dc:creator>
		<pubDate>Mon, 02 Feb 2009 10:21:55 +0000</pubDate>
		<guid isPermaLink="false">/blogs/hex/archive/2009/01/31/using-idataerrorinfo-in-an-asp-net-mvc-application-should-be-considered-worst-practice.aspx#comment-50</guid>
		<description>I agree that using exceptions to drive the flow of your program is not good practice. However saying that exceptions are for exceptional circumstances is ...a bit weak. An exception should be thrown if a violation of a contract occurs. In these examples that would be if the Save method was called on a model that was invalid. However you avoid the exception-based-flow by having an IsValid property/method. 
A tiny nit-pick I still have with all this MVC stuff I have seen is the use of string literals everywhere. Can &quot;edit&quot; be replaced with a const/enum/static-readonly for better discoverablility, ease of refactoring and compile time warning.
</description>
		<content:encoded><![CDATA[<p>I agree that using exceptions to drive the flow of your program is not good practice. However saying that exceptions are for exceptional circumstances is &#8230;a bit weak. An exception should be thrown if a violation of a contract occurs. In these examples that would be if the Save method was called on a model that was invalid. However you avoid the exception-based-flow by having an IsValid property/method.<br />
A tiny nit-pick I still have with all this MVC stuff I have seen is the use of string literals everywhere. Can &#8220;edit&#8221; be replaced with a const/enum/static-readonly for better discoverablility, ease of refactoring and compile time warning.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark</title>
		<link>http://lostechies.com/erichexter/2009/01/31/using-idataerrorinfo-in-an-asp-net-mvc-application-should-be-considered-worst-practice/#comment-49</link>
		<dc:creator>Mark</dc:creator>
		<pubDate>Mon, 02 Feb 2009 05:27:31 +0000</pubDate>
		<guid isPermaLink="false">/blogs/hex/archive/2009/01/31/using-idataerrorinfo-in-an-asp-net-mvc-application-should-be-considered-worst-practice.aspx#comment-49</guid>
		<description>@Colin: 

So if you have 100,000 users all submitting invalid forms and this performance would be an issue ??
</description>
		<content:encoded><![CDATA[<p>@Colin: </p>
<p>So if you have 100,000 users all submitting invalid forms and this performance would be an issue ??</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: schambers</title>
		<link>http://lostechies.com/erichexter/2009/01/31/using-idataerrorinfo-in-an-asp-net-mvc-application-should-be-considered-worst-practice/#comment-48</link>
		<dc:creator>schambers</dc:creator>
		<pubDate>Sun, 01 Feb 2009 14:29:37 +0000</pubDate>
		<guid isPermaLink="false">/blogs/hex/archive/2009/01/31/using-idataerrorinfo-in-an-asp-net-mvc-application-should-be-considered-worst-practice.aspx#comment-48</guid>
		<description>I dislike exception based programming as well. Exceptions IMO are used for EXCEPTIONAL circumstances. If data is missing then this is a basic domain validation, not an invalidoperationexception.

I&#039;ve maintained large amounts of exception based programming code and it&#039;s not pretty when you&#039;re throwing exceptions all over the place to control flow.</description>
		<content:encoded><![CDATA[<p>I dislike exception based programming as well. Exceptions IMO are used for EXCEPTIONAL circumstances. If data is missing then this is a basic domain validation, not an invalidoperationexception.</p>
<p>I&#8217;ve maintained large amounts of exception based programming code and it&#8217;s not pretty when you&#8217;re throwing exceptions all over the place to control flow.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
