<?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: Asp.Net MVC: My Personal View Rules</title>
	<atom:link href="http://elegantcode.com/2010/07/05/asp-net-mvc-my-personal-view-rules/feed/" rel="self" type="application/rss+xml" />
	<link>http://elegantcode.com/2010/07/05/asp-net-mvc-my-personal-view-rules/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=asp-net-mvc-my-personal-view-rules</link>
	<description></description>
	<lastBuildDate>Sun, 12 Feb 2012 18:54:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.5</generator>
	<item>
		<title>By: Jiho Han</title>
		<link>http://elegantcode.com/2010/07/05/asp-net-mvc-my-personal-view-rules/comment-page-2/#comment-58182</link>
		<dc:creator>Jiho Han</dc:creator>
		<pubDate>Tue, 20 Jul 2010 16:29:41 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/?p=3641#comment-58182</guid>
		<description>&lt;blockquote cite=&quot;#commentbody-58059&quot;&gt;
&lt;strong&gt;&lt;a href=&quot;#comment-58059&quot; rel=&quot;nofollow&quot;&gt;Chris Brandsma&lt;/a&gt; :&lt;/strong&gt;
Second, my preference is to have one set of domain classes specifically for the data access (Repository Domain), and separate Domain classes for Views, and sometimes different domain layers for other layers, and have a robust mapping layer.  This seems like a lot more work, but it actually keeps things much cleaner.
&lt;/blockquote&gt;

Do you have a code sample that demonstrate this?  It&#039;d be a lot easier to see this than to mentally map it out.  I&#039;d like to see the automapper/composition over inheritance action in code.

By the way, the comment system here is kind of wacky.  I was lost at first because your replies started on one page and the original comment ended on another.</description>
		<content:encoded><![CDATA[<blockquote cite="#commentbody-58059"><p>
<strong><a href="#comment-58059" rel="nofollow">Chris Brandsma</a> :</strong><br />
Second, my preference is to have one set of domain classes specifically for the data access (Repository Domain), and separate Domain classes for Views, and sometimes different domain layers for other layers, and have a robust mapping layer.  This seems like a lot more work, but it actually keeps things much cleaner.
</p></blockquote>
<p>Do you have a code sample that demonstrate this?  It&#8217;d be a lot easier to see this than to mentally map it out.  I&#8217;d like to see the automapper/composition over inheritance action in code.</p>
<p>By the way, the comment system here is kind of wacky.  I was lost at first because your replies started on one page and the original comment ended on another.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris Brandsma</title>
		<link>http://elegantcode.com/2010/07/05/asp-net-mvc-my-personal-view-rules/comment-page-2/#comment-58125</link>
		<dc:creator>Chris Brandsma</dc:creator>
		<pubDate>Wed, 14 Jul 2010 20:51:39 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/?p=3641#comment-58125</guid>
		<description>@Jusay:

setTimeout( function(){   
   $(myDivForTheResults).load(&quot;&lt;%=Url.Action(&quot;Action&quot;, &quot;Controller&quot;) %&gt;&quot;)
   }, 5);</description>
		<content:encoded><![CDATA[<p>@Jusay:</p>
<p>setTimeout( function(){<br />
   $(myDivForTheResults).load(&#8220;< %=Url.Action("Action", "Controller") %>&#8220;)<br />
   }, 5);</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jusay</title>
		<link>http://elegantcode.com/2010/07/05/asp-net-mvc-my-personal-view-rules/comment-page-2/#comment-58124</link>
		<dc:creator>Jusay</dc:creator>
		<pubDate>Wed, 14 Jul 2010 20:45:59 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/?p=3641#comment-58124</guid>
		<description>Great post. It has a very good tips. Thank you.

I have a question concerning the rule #7. In wich way or how do you use the setTimeout to call the load() function? Could you post an example or something like that?

Thanks a lot.</description>
		<content:encoded><![CDATA[<p>Great post. It has a very good tips. Thank you.</p>
<p>I have a question concerning the rule #7. In wich way or how do you use the setTimeout to call the load() function? Could you post an example or something like that?</p>
<p>Thanks a lot.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: RobertTheGrey</title>
		<link>http://elegantcode.com/2010/07/05/asp-net-mvc-my-personal-view-rules/comment-page-2/#comment-58121</link>
		<dc:creator>RobertTheGrey</dc:creator>
		<pubDate>Wed, 14 Jul 2010 18:45:34 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/?p=3641#comment-58121</guid>
		<description>Hey Chris,

Great article and very sound advice!

I hope you don&#039;t mind, but I intend to make quite a few references to your article in my talk at mvcconf.com next week to demonstrate how the Spark View Engine can help you achieve a lot of what you talk about here. If that&#039;s a problem for you, would you mind letting me know by email?

All the best,
Rob</description>
		<content:encoded><![CDATA[<p>Hey Chris,</p>
<p>Great article and very sound advice!</p>
<p>I hope you don&#8217;t mind, but I intend to make quite a few references to your article in my talk at mvcconf.com next week to demonstrate how the Spark View Engine can help you achieve a lot of what you talk about here. If that&#8217;s a problem for you, would you mind letting me know by email?</p>
<p>All the best,<br />
Rob</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris Brandsma</title>
		<link>http://elegantcode.com/2010/07/05/asp-net-mvc-my-personal-view-rules/comment-page-2/#comment-58108</link>
		<dc:creator>Chris Brandsma</dc:creator>
		<pubDate>Tue, 13 Jul 2010 16:10:06 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/?p=3641#comment-58108</guid>
		<description>@Rob: I have the greatest respect for Scott Guthrie, he is an amazing individual in Microsoft and doing excellent work.  But I can&#039;t recommend doing that.  Even for Scott, I can only imagine his thinking was that he only had 30 minutes to do a demo, and how could he cram as much in there as possible.

Demos to not equate good coding practices.

But, I will say this in defense of that method: if you can code the site, start to finish, in under 4 hours then I don&#039;t care what your code looks like.  Worst case you can rewrite the entire thing later.  If your project is going to take days to complete, then an ounce of prevention is worth a pound of cure.</description>
		<content:encoded><![CDATA[<p>@Rob: I have the greatest respect for Scott Guthrie, he is an amazing individual in Microsoft and doing excellent work.  But I can&#8217;t recommend doing that.  Even for Scott, I can only imagine his thinking was that he only had 30 minutes to do a demo, and how could he cram as much in there as possible.</p>
<p>Demos to not equate good coding practices.</p>
<p>But, I will say this in defense of that method: if you can code the site, start to finish, in under 4 hours then I don&#8217;t care what your code looks like.  Worst case you can rewrite the entire thing later.  If your project is going to take days to complete, then an ounce of prevention is worth a pound of cure.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rob Kent</title>
		<link>http://elegantcode.com/2010/07/05/asp-net-mvc-my-personal-view-rules/comment-page-2/#comment-58107</link>
		<dc:creator>Rob Kent</dc:creator>
		<pubDate>Tue, 13 Jul 2010 15:55:57 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/?p=3641#comment-58107</guid>
		<description>With regards to having separate Model and ViewModel objects, this becomes almost obligatory because you do not want your data model polluted with UI concerns, such as validation rules, etc. In most &#039;enterprise size&#039; applications you will be using different assemblies for your domain model, service layer, and UI so you will require something like AutoMapper to map between your domain and view models.

I saw an interesting variation in one of Scott Guthrie&#039;s screencasts where he was using Linq or EF and everything was in one project. He was therefore able to use a partial class for the domain model which included all the validation rules and UI hints. This approach will not work using separate assemblies because partial classes have to be in the same assembly but it is an interesting option for smaller-scale projects.</description>
		<content:encoded><![CDATA[<p>With regards to having separate Model and ViewModel objects, this becomes almost obligatory because you do not want your data model polluted with UI concerns, such as validation rules, etc. In most &#8216;enterprise size&#8217; applications you will be using different assemblies for your domain model, service layer, and UI so you will require something like AutoMapper to map between your domain and view models.</p>
<p>I saw an interesting variation in one of Scott Guthrie&#8217;s screencasts where he was using Linq or EF and everything was in one project. He was therefore able to use a partial class for the domain model which included all the validation rules and UI hints. This approach will not work using separate assemblies because partial classes have to be in the same assembly but it is an interesting option for smaller-scale projects.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Steve Py</title>
		<link>http://elegantcode.com/2010/07/05/asp-net-mvc-my-personal-view-rules/comment-page-2/#comment-58060</link>
		<dc:creator>Steve Py</dc:creator>
		<pubDate>Thu, 08 Jul 2010 22:42:47 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/?p=3641#comment-58060</guid>
		<description>@Chris: True, So long as the server respects the current client&#039;s Locale in both directions where applicable. In my experience, passing dates formatted as strings in anything other than ISO format eventually leads to pain.</description>
		<content:encoded><![CDATA[<p>@Chris: True, So long as the server respects the current client&#8217;s Locale in both directions where applicable. In my experience, passing dates formatted as strings in anything other than ISO format eventually leads to pain.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris Brandsma</title>
		<link>http://elegantcode.com/2010/07/05/asp-net-mvc-my-personal-view-rules/comment-page-2/#comment-58059</link>
		<dc:creator>Chris Brandsma</dc:creator>
		<pubDate>Thu, 08 Jul 2010 17:56:55 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/?p=3641#comment-58059</guid>
		<description>@Pierre, this might shock you a bit.  But I&#039;ve gone down that road before, and don&#039;t want to go there again.  In fact, I would not suggest it at all for a web application.  It complicates your ORM mapping considerably, and really serves no purpose that could not be better handled with composition.

So my CustomerInvoice would NOT inherit from Customer (or anything for that matter), but instead would have a Customer property.  What inevitably happens when you start using domain class inheritance is that you get domain classes with more crap properties than valuable ones.  Plus, now to hidrate the entity you have a tone more work that HAS to happen.  Not so with composition.

Second, my preference is to have one set of domain classes specifically for the data access (Repository Domain), and separate Domain classes for Views, and sometimes different domain layers for other layers, and have a robust mapping layer.  This seems like a lot more work, but it actually keeps things much cleaner.

But, in all fairness, my Domain (in the DDD sense) is not your Domain.  Mine works very well for me.  Not knowing your Domain, yours could work well for you, but not for me, and vise versa.</description>
		<content:encoded><![CDATA[<p>@Pierre, this might shock you a bit.  But I&#8217;ve gone down that road before, and don&#8217;t want to go there again.  In fact, I would not suggest it at all for a web application.  It complicates your ORM mapping considerably, and really serves no purpose that could not be better handled with composition.</p>
<p>So my CustomerInvoice would NOT inherit from Customer (or anything for that matter), but instead would have a Customer property.  What inevitably happens when you start using domain class inheritance is that you get domain classes with more crap properties than valuable ones.  Plus, now to hidrate the entity you have a tone more work that HAS to happen.  Not so with composition.</p>
<p>Second, my preference is to have one set of domain classes specifically for the data access (Repository Domain), and separate Domain classes for Views, and sometimes different domain layers for other layers, and have a robust mapping layer.  This seems like a lot more work, but it actually keeps things much cleaner.</p>
<p>But, in all fairness, my Domain (in the DDD sense) is not your Domain.  Mine works very well for me.  Not knowing your Domain, yours could work well for you, but not for me, and vise versa.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris Brandsma</title>
		<link>http://elegantcode.com/2010/07/05/asp-net-mvc-my-personal-view-rules/comment-page-1/#comment-58058</link>
		<dc:creator>Chris Brandsma</dc:creator>
		<pubDate>Thu, 08 Jul 2010 17:48:46 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/?p=3641#comment-58058</guid>
		<description>@Steve: Asp.Net MVC is not Silverlight/MVVM.  Different rules will apply.  Specifically because of the differences between the UI control sets.  Some of what I talked about works for Silverlight/MVVM, but the particular advice of converting everything to string (for Asp.Net MVC) does not apply to Silverlight/MVVM where you have control sets that natively read the DateTime type.</description>
		<content:encoded><![CDATA[<p>@Steve: Asp.Net MVC is not Silverlight/MVVM.  Different rules will apply.  Specifically because of the differences between the UI control sets.  Some of what I talked about works for Silverlight/MVVM, but the particular advice of converting everything to string (for Asp.Net MVC) does not apply to Silverlight/MVVM where you have control sets that natively read the DateTime type.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pierre Boucher</title>
		<link>http://elegantcode.com/2010/07/05/asp-net-mvc-my-personal-view-rules/comment-page-1/#comment-58057</link>
		<dc:creator>Pierre Boucher</dc:creator>
		<pubDate>Thu, 08 Jul 2010 17:39:13 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/?p=3641#comment-58057</guid>
		<description>Thank you Chris for this article. 

I particularly find interesting the ongoing discussion about rule #3 and what it means for the separation of concerns between layers. I think that inheritance should be used to build model classes.  

Generic business rules should be coded in a base model class (ex: Customer) and presentation rules should end up in an inherited model class (ex: CustomerInvoice).  In my example &#039;CustomerInvoice&#039; class would have the responsibilities of formating customers fields and validate data for its use in the context of an invoice. &#039;Customer&#039; class would also validate data but in the context of the business entity (ex: name should always be supplied no matter the context).

It could help maintainability and having classes closer to the data layer or to the presentation layer but not both while keeping most of the rules (business and presentation) out of the view. And its good OOP practice.</description>
		<content:encoded><![CDATA[<p>Thank you Chris for this article. </p>
<p>I particularly find interesting the ongoing discussion about rule #3 and what it means for the separation of concerns between layers. I think that inheritance should be used to build model classes.  </p>
<p>Generic business rules should be coded in a base model class (ex: Customer) and presentation rules should end up in an inherited model class (ex: CustomerInvoice).  In my example &#8216;CustomerInvoice&#8217; class would have the responsibilities of formating customers fields and validate data for its use in the context of an invoice. &#8216;Customer&#8217; class would also validate data but in the context of the business entity (ex: name should always be supplied no matter the context).</p>
<p>It could help maintainability and having classes closer to the data layer or to the presentation layer but not both while keeping most of the rules (business and presentation) out of the view. And its good OOP practice.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

