<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>.Net Smoothie &#187; MVC</title>
	<atom:link href="http://www.richardbushnell.net/category/mvc/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.richardbushnell.net</link>
	<description></description>
	<lastBuildDate>Wed, 30 Dec 2009 11:42:52 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>My own ASP.Net MVP Framework</title>
		<link>http://www.richardbushnell.net/2008/02/03/my-own-aspnet-mvp-framework/</link>
		<comments>http://www.richardbushnell.net/2008/02/03/my-own-aspnet-mvp-framework/#comments</comments>
		<pubDate>Sun, 03 Feb 2008 13:59:08 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[Architecture]]></category>
		<category><![CDATA[ASP.Net]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[MVP]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[framework]]></category>

		<guid isPermaLink="false">http://richardbushnell.net/index.php/2008/02/03/my-own-aspnet-mvp-framework/</guid>
		<description><![CDATA[So, I did it! I finally did it! I wanted to publish my ideas for a framework, and I did. You can find it on CodePlex at http://www.codeplex.com/aspnetmvp. Go have a look. I really want to know what you think. Now, I know there are a million and one frameworks for the web, so I [...]]]></description>
			<content:encoded><![CDATA[
<!-- using Like-Button-Plugin-For-Wordpress [v4.2] | by http://www.gb-world.net -->
<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.richardbushnell.net%2F2008%2F02%2F03%2Fmy-own-aspnet-mvp-framework%2F&amp;layout=standard&amp;show_faces=true&amp;width=450&amp;action=like&amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="false" style="border:none; overflow:; width:450px; height:30px"></iframe>
<!-- using Like-Button-Plugin-For-Wordpress [v4.2] | by http://www.gb-world.net -->
<br><p>So, I did it! I finally did it!</p>
<p>I wanted to publish my ideas for a framework, and I did. You can find it on CodePlex at <a href="http://www.codeplex.com/aspnetmvp">http://www.codeplex.com/aspnetmvp</a>.</p>
<p>Go have a look. I really want to know what you think.</p>
<p><span id="more-44"></span></p>
<p>Now, I know there are a million and one frameworks for the web, so I don&#8217;t intend on trying to make anything  big out of this. But I also know that my customers, usually decent developers with basic ASP.Net knowledge, are constantly asking me for guidance for creating ASP.Net projects. To avoid repeating myself over and over, this project gives them a good starting point. When something better comes along, I can point them to that instead.</p>
<p>I can also use the project as a place for creating new ideas, like</p>
<ul>
<li>WF integration and reusable workflows, like shopping carts or the &#8220;hub and spoke UI pattern&#8221;.</li>
<li>plug-ins and skins, like Dotnetnuke</li>
</ul>
<p>I definitely do not want to reinvent the wheel. But I believe that there are currently loads of great ideas which could be used in a framework, but just require a little bit of effort to make them simple to use (e.g. UrlRewriting). Most of the developers I know want those extra features without having to spend a lot of time learning a new technology. This framework should be for them.</p>
<p>Instead of totally turning the heads of such developers around, asking them to use a completely new system (e.g. the ASP.Net MVC framework), this framework is meant to provide helpful stuff without stopping you from doing things the way you want (favicons and robots.txt files, for example). It gives you guidance on where to put your CSS files, master pages, scripts, and images. It also provides a way to do testing and project management in a sensible and flexible way. It uses the MVP pattern, but that isn&#8217;t mandatory. You can still write code in webforms if you really want to, and then you can refactor them out quite easily later.</p>
<p>I based my MVP implementation on some of the code from the Microsoft Patterns and Practices Web Client Software Factory. However, they made extensive use of the ObjectBuilder and attributes, which I found to be overengineering and too complex. So, as an alternative, I recreated the ideas using generics. I found it works well, and doesn&#8217;t have the performance overhead or the learning curve required with WCS.</p>
<p>The code currently uses the AdventureWorks Database, which you will need to install first before using the code. You can find the database on CodePlex here.</p>
<p>I&#8217;m currently working on another top-secret project, so I won&#8217;t really be spending much time on this. If you&#8217;re interested in discussing ideas or doing something with the project, let me know. I&#8217;d love to hear what you have to offer.</p>
<p>Otherwise, head on over to the <a href="http://www.codeplex.com/aspnetmvp">ASP.Net MVP Framework site</a>, and check out the code.</p>
<p>Oh, and until the lawyers call and ask me to change the name, let&#8217;s just leave it as it is.</p>
<p>P.S. I forgot to mention a &#8220;feature&#8221;. The Yahoo UI Framework has some great stuff for CSS, including grid layouts and css reset files. I integrated that too. I put it in the default theme. It means you don&#8217;t have to do much work to get your stylesheets to lay out your webpages well.</p>
<p>More to come on that later.</p>

<!-- using Like-Button-Plugin-For-Wordpress [v4.2] | by http://www.gb-world.net -->
<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.richardbushnell.net%2F2008%2F02%2F03%2Fmy-own-aspnet-mvp-framework%2F&amp;layout=standard&amp;show_faces=true&amp;width=450&amp;action=like&amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="false" style="border:none; overflow:; width:450px; height:30px"></iframe>
<!-- using Like-Button-Plugin-For-Wordpress [v4.2] | by http://www.gb-world.net -->
]]></content:encoded>
			<wfw:commentRss>http://www.richardbushnell.net/2008/02/03/my-own-aspnet-mvp-framework/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>ASP.Net MVC Corollary &#8211; What to do?</title>
		<link>http://www.richardbushnell.net/2008/01/28/aspnet-mvc-corollary-what-to-do/</link>
		<comments>http://www.richardbushnell.net/2008/01/28/aspnet-mvc-corollary-what-to-do/#comments</comments>
		<pubDate>Mon, 28 Jan 2008 03:50:31 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[ASP.Net]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[Refactoring]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[SubSonic]]></category>

		<guid isPermaLink="false">http://richardbushnell.net/index.php/2008/01/28/aspnet-mvc-corollary-what-to-do/</guid>
		<description><![CDATA[Dude! I got quoted! And by none other than Rob Conery of SubSonic fame. It seems like my last post caused quite an unexpected stir. Thanks to both Rob and Scott for taking the time to answer me. I really appreciate it. A Word of Appreciation Let&#8217;s get something in perspective. Rob has actually produced [...]]]></description>
			<content:encoded><![CDATA[
<!-- using Like-Button-Plugin-For-Wordpress [v4.2] | by http://www.gb-world.net -->
<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.richardbushnell.net%2F2008%2F01%2F28%2Faspnet-mvc-corollary-what-to-do%2F&amp;layout=standard&amp;show_faces=true&amp;width=450&amp;action=like&amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="false" style="border:none; overflow:; width:450px; height:30px"></iframe>
<!-- using Like-Button-Plugin-For-Wordpress [v4.2] | by http://www.gb-world.net -->
<br><p>Dude! I got <a href="http://blog.wekeroad.com/2008/01/25/ramble-aspnet-mvc-is-a-geek-chisel/" target="_blank">quoted</a>! And by none other than Rob Conery of SubSonic fame.</p>
<p>It seems like my <a href="http://richardbushnell.net/index.php/2008/01/25/does-the-aspnet-mvc-framework-frustrate-you/" target="_blank">last post</a> caused quite an unexpected stir. Thanks to both <a href="http://blog.wekeroad.com/2008/01/25/ramble-aspnet-mvc-is-a-geek-chisel/" target="_blank">Rob</a> and <a href="http://www.hanselman.com/blog/" target="_blank">Scott</a> for taking the time to answer me. I really appreciate it.<br />
<span id="more-43"></span></p>
<h2>A Word of Appreciation</h2>
<p>Let&#8217;s get something in perspective. Rob has actually <em>produced</em> something of immense value with SubSonic. I have just <em>complained </em>about it. Rob could very easily have just hammered me down, but he didn&#8217;t. Thanks, Rob.</p>
<p>Scott too.</p>
<p>In the <a href="http://www.hanselman.com/blog/HanselminutesPodcast98RaisingGeeksWithScottsDad.aspx" target="_blank">last episode of his most excellent podcast</a>, Scott said to his Dad that he likes to stir things up. &#8220;Presenting options&#8221; was the phrase I think he used. In that case, we are two peas in a pod. I <em>always</em> like to ask questions. If my question uncovers an unjustified assumption, things usually get better. If I&#8217;m wrong, then at least I come out knowing why I was wrong and understand the problem better.</p>
<p>While studying for my physics degree, I was asked to give feedback for a course on &#8220;Cosmic Dust&#8221;. I commented that it was just a completely pointless course. I mean, why waste 12 weeks of lectures studying the invisible dust floating around in space? Instead of numbing our brains with such useless information, we could have been learning something much more relevant. That particular comment, although made privately, really stirred up the lecturer. He got quite mad actually. He even wrote a long letter to the students with his  reasoning for why cosmic dust was so important. That itself was unprecedented. No lecturer had ever given us feedback to our feedback before.</p>
<p>Not much changed in the end, but at least I came out of it understanding more about what I&#8217;d been doing. Maybe that will happen with ASP.Net MVC.</p>
<p>So thanks to both of you for taking me seriously.</p>
<h2>How Dare They!</h2>
<p>Last month I watched a documentary about J.K. Rowling. It followed her as she completed and published the 7th and final Harry Potter book. It was the fasting selling book of all time. Truly amazing. But what amazed me most about the whole documentary was a comment made by two girls who had been queuing all night to get their copy of the book:</p>
<blockquote><p>&#8220;Finally! We&#8217;ve been waiting 10 years for this!&#8221;</p></blockquote>
<p>The remark was made with a tinge of disgust. It was as if the author had no right to take such a long time writing the book. How dare Mrs Rowling take so much time to finish her book while they had to suffer while sitting around waiting for it. How inconvenient for them! How inconsiderate of Mrs Rowling!</p>
<p>I thought, &#8220;if you wanted the book so much, why didn&#8217;t you write your own?&#8221;</p>
<p>In that spirit, I&#8217;m going to try to do something about the ASP.Net MVC thing myself. I don&#8217;t want to be that kind of person that complains but does nothing.</p>
<h2>Wait! There&#8217;s a baby in that bath-water!</h2>
<p>I read <a href="http://blog.wekeroad.com/2008/01/25/ramble-aspnet-mvc-is-a-geek-chisel/" target="_blank">Rob&#8217;s readers&#8217; comments</a>, and I think that it doesn&#8217;t require a full rewrite of ASP.Net to do what they want. In fact, I already wrote a bit of code, modeled loosely on <a href="http://www.djangoproject.com/documentation/templates/" target="_blank">Django templates</a>, which allows an ASP.Net developer to control the page output pretty much the same way as MVC promises to do. I&#8217;ll have to dig the code out of its hiding place, but then I plan to integrate it with a small Model-View-Presenter framework (a couple of generic base-classes for a Page and Presenter) which will enable a much better way for writing pages than the normal ASP.Net pages do. It also allows full testing of the controlling code.</p>
<p>And better yet, the MVP stuff is based on a refactored and simplified version of some Patterns and Practices code. (Yaaay, we can all be happy together!)</p>
<p>I&#8217;ve used this pattern, and each Presenter class is usually a few lines long. My ASP.Net page only contains presentation logic, i.e. stuff to render the page and retrieve input. I don&#8217;t need a controller nor a completely new framework to do it. In fact, a Controller class would be much worse, IMHO, because Controllers contain the code for more than one concern &#8211; a list page, an edit page, a delete page, etc. (I think that those things could be pragmatically abstracted and made easier anyhow, but that&#8217;s another story.) I personally prefer to keep my concerns separate.</p>
<p>And I&#8217;m not the only one who likes MVP. <a href="http://weblogs.asp.net/craigshoemaker/archive/2007/12/06/podcast-asp-net-mvc-and-the-future-of-model-view-presenter-interview-with-jeffery-palermo.aspx" target="_blank">Craig Shoemaker</a> does too.</p>
<p>So here&#8217;s my plan: I&#8217;ll try to publish some ideas and persuade you all to use them. Then I&#8217;ll get Microsoft to take Routes, Controllers, and whatever other goodies they&#8217;ve got in ASP.Net MVC, and put them in the next full-blown version of ASP.Net. Then everyone can use them and we can carry on with life as normal. I won&#8217;t have to use UrlRewriter to do my Routing any more and Microsoft can go back and finish off Workflow Foundation, ASP.Net Ajax, and Patterns and Practices.</p>
<p>Well, that&#8217;s the plan, anyway.</p>
<p>(I&#8217;ve just got to tidy up some of my code before I publish it. Give me a moment&#8230;)</p>

<!-- using Like-Button-Plugin-For-Wordpress [v4.2] | by http://www.gb-world.net -->
<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.richardbushnell.net%2F2008%2F01%2F28%2Faspnet-mvc-corollary-what-to-do%2F&amp;layout=standard&amp;show_faces=true&amp;width=450&amp;action=like&amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="false" style="border:none; overflow:; width:450px; height:30px"></iframe>
<!-- using Like-Button-Plugin-For-Wordpress [v4.2] | by http://www.gb-world.net -->
]]></content:encoded>
			<wfw:commentRss>http://www.richardbushnell.net/2008/01/28/aspnet-mvc-corollary-what-to-do/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Does the ASP.Net MVC Framework Frustrate You?</title>
		<link>http://www.richardbushnell.net/2008/01/25/does-the-aspnet-mvc-framework-frustrate-you/</link>
		<comments>http://www.richardbushnell.net/2008/01/25/does-the-aspnet-mvc-framework-frustrate-you/#comments</comments>
		<pubDate>Fri, 25 Jan 2008 09:11:06 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[ASP.Net MVC]]></category>
		<category><![CDATA[SubSonic]]></category>
		<category><![CDATA[trends]]></category>

		<guid isPermaLink="false">http://richardbushnell.net/index.php/2008/01/25/does-the-aspnet-mvc-framework-frustrate-you/</guid>
		<description><![CDATA[Silverlight, ASP.Net Ajax, LINQ, Astoria, ASP.Net MVC &#8211; there&#8217;s just tons of stuff coming out of Microsoft. And that&#8217;s not to mention the stuff people have seemingly forgotten about &#8211; ASP.Net Futures with IronPython (AWOL), Patterns and Practices Web Client Software Factory, WPF, WF, WCF and CardSpaces. Now the trend seems to be functional programming [...]]]></description>
			<content:encoded><![CDATA[
<!-- using Like-Button-Plugin-For-Wordpress [v4.2] | by http://www.gb-world.net -->
<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.richardbushnell.net%2F2008%2F01%2F25%2Fdoes-the-aspnet-mvc-framework-frustrate-you%2F&amp;layout=standard&amp;show_faces=true&amp;width=450&amp;action=like&amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="false" style="border:none; overflow:; width:450px; height:30px"></iframe>
<!-- using Like-Button-Plugin-For-Wordpress [v4.2] | by http://www.gb-world.net -->
<br><p>Silverlight, ASP.Net Ajax, LINQ, Astoria, ASP.Net MVC &#8211; there&#8217;s just tons of stuff coming out of Microsoft. And that&#8217;s not to mention the stuff people have seemingly forgotten about &#8211; ASP.Net Futures with IronPython (AWOL), Patterns and Practices Web Client Software Factory, WPF, WF, WCF and CardSpaces. Now the trend seems to be functional programming languages, especially with F#.</p>
<p>There&#8217;s just a bit <em>too</em> much for me.</p>
<p>What I really need is guidance. My customers don&#8217;t ask me what to they should use in 6 months; they ask me how to use what already exists. They don&#8217;t want &#8220;cool&#8221;; they want stability and consistency. And while the ball keeps moving, we can&#8217;t grab it.<br />
<span id="more-39"></span></p>
<p>Take for example, the ASP.Net Futures framework. I recently took over a project where it had been used. I checked to see what was available now &#8211; nothing! It seems to be dead. I&#8217;ll have to rip it out of the project, somehow. Major headache!</p>
<p>MSDN Patterns and Practices have produced some great stuff recently. Policy Injection, ObjectBuilder, PageFlows, Validators; but it&#8217;s completely ignored, as no one has a chance to look at it because of all the other stuff grabbing their attention. Well that, and the fact that it looks a bit overengineered.</p>
<p>While this is happening, and the cool guys are playing with all the new stuff, the guys on the ground are wondering what they should learn and what not. LINQ is hard enough to learn, and most developers haven&#8217;t even looked at the near 18-month-old WF suite yet. There just isn&#8217;t time.</p>
<p>I recently heard Dino Esposito say the same thing. I heard him on <a href="http://www.intellectualhedonism.com/2007/10/16/NETRocks281DinoEspositoOnAJAXArchitecture.aspx" target="_blank">DotNetRocks</a> bemoaning the fact that Microsoft seems to have abandoned ASP.Net Ajax to chase after Silverlight. They could have made ASP.Net Ajax absolutely fantastic, but aren&#8217;t doing anything about it any more. Seems like it&#8217;s finished.</p>
<p>But above it all, the MVC Framework just tips the scale for me.</p>
<p>Let me start with some history. About 18 months ago, I heard Scott Hanselman say in <a href="http://www.hanselminutes.com/default.aspx?showID=40" target="_blank">his podcast</a> that Ruby On Rails was <em>the framework</em> that Scott Guthrie and Microsoft should be worried about. I agreed. In fact, I went and learnt Rails because of that. I found it was really good, just like he said (apart from when you try to get a site deployed, at which point you need a degree in Rocket Science or a great hosting company. I had neither.) But the concepts I learnt from Rails were very interesting. I tried to apply them in my work.</p>
<p>Enter <a href="http://blog.wekeroad.com/2008/01/14/subsonic-and-mvc-introducing-makai/" target="_blank">SubSonic</a>. Rob Conery made a great implementation of the ActiveRecord pattern from Rails for .Net and called it SubSonic. He even included some of the syntactic sugar that makes Rails fun. It is a great framework, and I suggested to some customers that they use it. They tried. They failed. I asked them why, and they answered that it just didn&#8217;t go far enough. They went back to using DataAdapters.</p>
<p><a href="http://blog.wekeroad.com/2007/10/26/microsoft-subsonic-and-me/" target="_blank">Rob</a> and Scott both work for Scott Guthrie now. <a href="http://www.hanselman.com/blog/ASPNETMVCWebFormsUnplugged.aspx" target="_blank">They seemingly focus on the ASP.Net MVC Framework</a>, which, unsurprisingly, is a blatant attempt at a copy of Rails.</p>
<p>Whether or not it&#8217;s a good framework (and I think it is), the problem is, I need some features for the stuff I&#8217;ve already got. I might need Routes (ala Rails) for my ASP.Net apps; I don&#8217;t need a complete new system for building pages. It just took me 3 years to learn ASP.Net as it is now. I don&#8217;t want to throw it all away because it&#8217;s not cool any more. And I don&#8217;t think my customers want to do that neither.</p>
<p>Why not make ASP.Net better? Why not take the stuff in Patterns and Practices and make it simpler to understand. That&#8217;s what happened with C-Omega and C#3.0. The good stuff from a research project found its way into the next version of the more popular language. Thumbs up to Anders!</p>
<p>I think that Microsoft could actually do a much better job at Rails than DHH did. Sure, he gave them a kick in the butt, but that&#8217;s a good thing.</p>
<p>Rails has things in it which we don&#8217;t need in ASP.Net. Multiple views are often necessary for creating REST API&#8217;s &#8211; how often do ASP.Net developers do that? If we do, we have business objects and other ways to support an API. Routes using controllers is for nice-looking URLs, especially useful for search engines &#8211; how many pages of our sites do most ASP.Net developers want to post to search engines? MVC is to make it simpler to control what goes into markup, and what goes into a view &#8211; we already have MVP, which fits well in ASP.Net, and doesn&#8217;t lead to huge controller files. (What&#8217;s a controller anyhow?)</p>
<p>And don&#8217;t forget that Rails doesn&#8217;t have the concepts of security built in. It doesn&#8217;t have controls. Try integrating plugins &#8211; it&#8217;s not always easy. And despite the TextMate craze, the IDE is pitiful. You have to know Ruby well before you can do anything.</p>
<p>On the ASP.Net side, do we really want to kick out viewstate? It was put there for a purpose. Real-world website developers were having trouble managing the control of forms in ASP, and ViewState was a good answer. Rails doesn&#8217;t have that. It does everything with IDs in forms. Cool, but if it&#8217;s put into ASP.Net MVC, it means we&#8217;ll have to learn a completely new model to achieve the same purpose.</p>
<p>The real reason I&#8217;m peed off, is that I&#8217;m having to invent my own guidance, while MS seems to be messing about doing other things. That&#8217;s not good for the customers, as they get new ideas from everyone, and no idea what is right or wrong.</p>
<p>So guys, please. Why not stop what we&#8217;re doing, take a step back, consolidate, learn from each other, and build something better than ever.</p>

<!-- using Like-Button-Plugin-For-Wordpress [v4.2] | by http://www.gb-world.net -->
<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.richardbushnell.net%2F2008%2F01%2F25%2Fdoes-the-aspnet-mvc-framework-frustrate-you%2F&amp;layout=standard&amp;show_faces=true&amp;width=450&amp;action=like&amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="false" style="border:none; overflow:; width:450px; height:30px"></iframe>
<!-- using Like-Button-Plugin-For-Wordpress [v4.2] | by http://www.gb-world.net -->
]]></content:encoded>
			<wfw:commentRss>http://www.richardbushnell.net/2008/01/25/does-the-aspnet-mvc-framework-frustrate-you/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
		<item>
		<title>ASP.Net MVC Framework leads you to extension method heaven</title>
		<link>http://www.richardbushnell.net/2007/12/12/aspnet-mvc-framework-made-public/</link>
		<comments>http://www.richardbushnell.net/2007/12/12/aspnet-mvc-framework-made-public/#comments</comments>
		<pubDate>Wed, 12 Dec 2007 13:26:07 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[ASP.Net]]></category>
		<category><![CDATA[MVC]]></category>

		<guid isPermaLink="false">http://richardbushnell.net/?p=5</guid>
		<description><![CDATA[The first pre-release of new ASP.Net MVC (ahem, Ruby-on-Rails for .Net) framework has just been made public. I find it really exciting that Scott Guthrie and his team are listening to what the people want. Webforms is really quite heavy, especially in comparison to Ruby on Rails, so by offering new frameworks Microsoft will gain [...]]]></description>
			<content:encoded><![CDATA[
<!-- using Like-Button-Plugin-For-Wordpress [v4.2] | by http://www.gb-world.net -->
<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.richardbushnell.net%2F2007%2F12%2F12%2Faspnet-mvc-framework-made-public%2F&amp;layout=standard&amp;show_faces=true&amp;width=450&amp;action=like&amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="false" style="border:none; overflow:; width:450px; height:30px"></iframe>
<!-- using Like-Button-Plugin-For-Wordpress [v4.2] | by http://www.gb-world.net -->
<br><p>The first <a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=A9C6BC06-B894-4B11-8300-35BD2F8FC908&amp;displaylang=en">pre-release of new ASP.Net MVC</a> (ahem, Ruby-on-Rails for .Net) framework has just been made public.</p>
<p>I find it really exciting that Scott Guthrie and his team are listening to what the people want. Webforms is really quite heavy, especially in comparison to Ruby on Rails, so by offering new frameworks Microsoft will gain new developers. And new developers equals more servers, so it&#8217;s a good business model, methinks.</p>
<p>A major plus for me is seeing how the Framework shows off the new C# 3.0 features. I love Python and Ruby, but with no support yet for Visual Studio, it&#8217;s not easy to use them. Until now, the expressiveness of Python and Ruby have been missing from C# &#8211; it grew up from Java after all – but C# 3.0 is now moving towards that expressiveness too. With XAML and C#, things have really changed for developers over the past 5 or so years.</p>
<p>For example, check out <a href="http://blog.wekeroad.com/2007/12/05/aspnet-mvc-preview-using-the-mvc-ui-helpers/">this post</a> from <a href="http://blog.wekeroad.com/">Rob Conery</a>. He demonstrates an extension method which allows you to create a list of attributes as a string. You just call &#8220;ToAttributeList()&#8221; on any object, and you get a string back like &#8220;field1=&#8221;0&#8243; field2=&#8221;1&#8243;&#8221;.</p>
<p>I can already think of loads of places where I would like to use that. There&#8217;s already a &#8220;ToDictionary()&#8221; method in the .Net 3.5 Framework, which can be used to create a dictionary from a list of objects, using a field as the key, but I can create a dictionary directly using the property names as keys, with the objects as values.</p>
<p><span style="font-family:Consolas;font-size:9pt;"><span style="color:blue;">public </span><span style="color:blue;">static </span><span style="color:#2b91af;">Dictionary</span>&lt;<span style="color:blue;">string</span>, <span style="color:blue;">object</span>&gt; ToPropertyHash(<span style="color:blue;">this </span><span style="color:blue;">object</span> item)<br />
{<br />
<span style="color:blue;">  var</span> props = <span style="color:blue;">from</span> property <span style="color:blue;">in</span> item.GetType().GetProperties()<br />
<span style="color:blue;">              select </span><span style="color:blue;">new</span> {Name=property.Name, Value=property.GetValue(item, <span style="color:blue;">null</span>)};</span><br />
<span style="font-family:Consolas;font-size:9pt;"><span style="color:blue;">var</span> dict = <span style="color:blue;">new </span><span style="color:#2b91af;">Dictionary</span>&lt;<span style="color:blue;">string</span>, <span style="color:blue;">object</span>&gt;();</span><br />
<span style="font-family:Consolas;font-size:9pt;"><span style="color:blue;">foreach</span>(<span style="color:blue;">var</span> prop <span style="color:blue;">in</span> props)<br />
{<br />
dict.Add(prop.Name, prop.Value);<br />
}</span><br />
<span style="font-family:Consolas;font-size:9pt;"><span style="color:blue;">return</span> dict;<br />
}</span></p>
<p>Here&#8217;s testing code which demonstrates what you get.</p>
<p><span style="font-family:Consolas;font-size:9pt;"><span style="color:blue;">      var</span> myObject = <span style="color:blue;">new</span> { Name = <span style="color:#a31515;">&#8220;Frank&#8221;</span>, Age = 5 };<br />
<span style="color:blue;">var</span> dict = myObject.ToPropertyHash();<br />
<span style="color:#2b91af;">CollectionAssert</span>.Contains(dict.Keys, <span style="color:#a31515;">&#8220;Name&#8221;</span>);<br />
<span style="color:#2b91af;">CollectionAssert</span>.Contains(dict.Keys, <span style="color:#a31515;">&#8220;Age&#8221;</span>);<br />
<span style="color:#2b91af;">Assert</span>.AreEqual(dict[<span style="color:#a31515;">"Name"</span>], <span style="color:#a31515;">&#8220;Frank&#8221;</span>);<br />
<span style="color:#2b91af;">Assert</span>.AreEqual(dict[<span style="color:#a31515;">"Age"</span>], 5);</span></p>
<p>Maybe that&#8217;s not so interesting for you, but I am developing Windows Workflow Foundation apps, and a workflow instance always requires you to build a new dictionary with the names of the properties as keys. This could be very, very helpful to cut down on code for that.</p>
<p>Instead of …</p>
<p><span style="font-family:Consolas;font-size:9pt;"><span style="color:#2b91af;">      Dictionary</span>&lt;<span style="color:blue;">string</span>, <span style="color:blue;">object</span>&gt; args = <span style="color:blue;">new</span><span style="color:#2b91af;"> Dictionary</span>&lt;<span style="color:blue;">string</span>, <span style="color:blue;">object</span>&gt;();<br />
args.Add(<span style="color:#a31515;">&#8220;Name&#8221;</span>, <span style="color:#a31515;">&#8220;Richard Bushnell&#8221;</span>);<br />
args.Add(<span style="color:#a31515;">&#8220;Age&#8221;</span>, 32);<br />
args.Add(<span style="color:#a31515;">&#8220;NoOfKids&#8221;</span>, 5);<br />
</span></p>
<p>… I use:<span style="font-family:Consolas;font-size:9pt;"><span style="color:blue;"></span></span></p>
<p><span style="font-family:Consolas;font-size:9pt;"><span style="color:blue;">var</span> args = <span style="color:blue;">new</span> { Name = <span style="color:#a31515;">&#8220;Richard Bushnell&#8221;</span>, Age = 32, NoOfKids = 5 }.ToPropertyHash();</span></p>
<p>What I cannot understand yet, is why Microsoft has to copy Ruby On Rails? Don&#8217;t get me wrong, I love Rails. But in some places it just doesn&#8217;t suit ASP.net development. ASP.net developers already have their ways of working, and have bought controls, etc. Why force them to not use them anymore, if they just want to tidy up their code with a new MVC model? Wouldn&#8217;t it be best for everyone if they developed another kind of framework? The focus could be on testing, as with MVC, but more directed towards developers who already use WinForms and WebForms.</p>
<p>Microsoft <em>can</em> develop independently. Take LINQ, for example. The .Net team could have simply provided list comprehensions as implemented in Python, but instead, they came up with a totally new model which no other development framework has ever had. And while XAML is similar to the old Delphi DFM files, it&#8217;s still taken some good leaps forward. I don&#8217;t see that yet with the ASP.Net MVC Framework. They&#8217;re still playing catch-up with Rails.</p>
<p>In general though, I&#8217;m really excited to watch it developing.</p>

<!-- using Like-Button-Plugin-For-Wordpress [v4.2] | by http://www.gb-world.net -->
<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.richardbushnell.net%2F2007%2F12%2F12%2Faspnet-mvc-framework-made-public%2F&amp;layout=standard&amp;show_faces=true&amp;width=450&amp;action=like&amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="false" style="border:none; overflow:; width:450px; height:30px"></iframe>
<!-- using Like-Button-Plugin-For-Wordpress [v4.2] | by http://www.gb-world.net -->
]]></content:encoded>
			<wfw:commentRss>http://www.richardbushnell.net/2007/12/12/aspnet-mvc-framework-made-public/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
	</channel>
</rss>

