<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://devlicio.us/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>ViNull, Off the Record : mvc</title><link>http://devlicio.us/blogs/vinull/archive/tags/mvc/default.aspx</link><description>Tags: mvc</description><dc:language>en</dc:language><generator>CommunityServer 2008.5 SP1 (Build: 31106.3070)</generator><item><title>The ASP.NET MVC Definition</title><link>http://devlicio.us/blogs/vinull/archive/2008/07/26/the-asp-net-mvc-definition.aspx</link><pubDate>Sat, 26 Jul 2008 16:35:38 GMT</pubDate><guid isPermaLink="false">40756a8b-6212-4073-9d98-6c26781577de:41475</guid><dc:creator>Michael C. Neel</dc:creator><slash:comments>10</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://devlicio.us/blogs/vinull/rsscomments.aspx?PostID=41475</wfw:commentRss><comments>http://devlicio.us/blogs/vinull/archive/2008/07/26/the-asp-net-mvc-definition.aspx#comments</comments><description>&lt;p&gt;&lt;a title="Luminous Idea by Tiago Daniel" href="http://flickr.com/photos/bazik/395792175/"&gt;&lt;img style="border-top-width:0px;border-left-width:0px;border-bottom-width:0px;margin:0px 10px 10px 0px;border-right-width:0px;" height="244" alt="image" src="http://devlicio.us/blogs/vinull/WindowsLiveWriter/TheASP.NETMVCDefinition_AAE1/image_3.png" width="189" align="left" border="0" /&gt;&lt;/a&gt; A few days ago I &lt;a href="http://www.vinull.com/Post/2008/07/25/the-mvc-minefield.aspx"&gt;posted a question to the community, looking for a definition of the ASP.NET MVC framework&lt;/a&gt; that didn&amp;#39;t depend upon faults in ASP.NET WebForms - after all, faults can be fixed.&amp;#160; I also do not like the implication that ASP.NET MVC is for those looking to use the MVC pattern, as I&amp;#39;ve been using that pattern for a decade and I use it in WebForms today.&amp;#160; Credit goes to &lt;a href="http://devlicio.us/blogs/vinull/archive/2008/07/25/the-mvc-minefield.aspx#41465"&gt;Lucas Goodwin&lt;/a&gt; for helping me with the following definition:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;ASP.NET MVC is the evolution of Classic ASP.&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;I&amp;#39;ve helped a number of developers move from Classic ASP to ASP.NET, and each one has said to me, &amp;quot;wow, this is nothing like ASP&amp;quot; once they groked it.&amp;#160; This is true, and mostly because WebForms introduced an event based paradigm to ASP.&amp;#160; Classic ASP had problems, but was the lack of events one of them?&lt;/p&gt;  &lt;p&gt;Classic ASP&amp;#39;s number one problem was lack of separation of concerns.&amp;#160; This is the same reason I don&amp;#39;t like PHP, my code is far to friendly with my HTML (&lt;em&gt;&lt;a href="http://www.youtube.com/watch?v=yJQFf0qj9Nk"&gt;gotta keep em&amp;#39; separated&lt;/a&gt;&lt;/em&gt;).&amp;#160; True you can discipline yourself to provide a separation, but it&amp;#39;s not something the framework designers gave much thought to.&lt;/p&gt;  &lt;p&gt;WebForms fixed the separation issue, but at the same time brought in the event model.&amp;#160; I liked this &amp;quot;magic controller&amp;quot; approach, because it saves me the time I used to spend wiring up controllers that just ended up back at the same template I started with.&amp;#160; (For the record, I was mostly working with python before moving to WebForms, first with a framework called Albatross and later SnakeSkin)&amp;#160; An event model is not required to have separation of concerns, and this forced an event model on to many Classic ASP developers.&amp;#160; So I will add a bit to the definition:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;ASP.NET MVC is the evolution of Classic ASP, adding an easier separation of concerns while not using an event based model like WebForms.&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;So do you agree or disagree?&amp;#160; I like this definition because it&amp;#39;s not claiming either approach is better, and I can look to the pros and cons of an event based model to guide me in selecting MVC or WebForms for a project.&amp;#160; It also is less likely to cause rioting in the streets at your next user group meeting when the topic comes up!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=41475" width="1" height="1"&gt;</description><category domain="http://devlicio.us/blogs/vinull/archive/tags/Featured/default.aspx">Featured</category><category domain="http://devlicio.us/blogs/vinull/archive/tags/opinion/default.aspx">opinion</category><category domain="http://devlicio.us/blogs/vinull/archive/tags/mvc/default.aspx">mvc</category></item><item><title>The MVC Minefield</title><link>http://devlicio.us/blogs/vinull/archive/2008/07/25/the-mvc-minefield.aspx</link><pubDate>Fri, 25 Jul 2008 04:22:24 GMT</pubDate><guid isPermaLink="false">40756a8b-6212-4073-9d98-6c26781577de:41448</guid><dc:creator>Michael C. Neel</dc:creator><slash:comments>14</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://devlicio.us/blogs/vinull/rsscomments.aspx?PostID=41448</wfw:commentRss><comments>http://devlicio.us/blogs/vinull/archive/2008/07/25/the-mvc-minefield.aspx#comments</comments><description>&lt;p&gt;There is a bit of turbulence in the ASP.NET airspace over MVC (yes, I&amp;#39;m making this post while on the fight back from the ASPInsiders Summit).&amp;#160; Even among the ASPInsiders, who are supposed to be at the cutting edge of ASP.NET, there is little agreement over what is MVC and what it&amp;#39;s for.&lt;/p&gt;  &lt;p&gt;MVC, or Model View Controller, is an age old pattern found in many places.&amp;#160; ASP.NET providers follow the pattern, as does Service Oriented Architecture.&amp;#160; The general idea to have some code called a Model that works with your data storage, other code called a View that displays the data, and last plumbing code that ties these two together, called the Controller.&amp;#160; I call it a pattern because implementations differ in the details - the View may render a button, but when the user clicks that button should the click action be handled by the View or Controller?&amp;#160; The Model and View should know nothing of each other, but is the Controller allowed to be tightly coupled to them both?&amp;#160; (If your first thought above was the Controller should handle the button action, think now what this means about being loosely coupled between the View and Controller). &lt;/p&gt;  &lt;p&gt;ASP.NET MVC is a framework in development that is intended to closely match the MVC pattern.&amp;#160; The minefield lies in answering the pragmatic question of what does ASP.NET MVC offer over WebForms, and when would you use MVC?&amp;#160; In taking with those excited by MVC the reasons range from supporting TDD, clean URLs and avoiding postbacks by sending actions to a controller, better control over HTML output (including getting rid of ViewState), and being closer to the http protocol.&lt;/p&gt;  &lt;p&gt;TDD, or Test Driven Development, will always come up in any ASP.NET MVC conversation, but TDD itself isn&amp;#39;t an explicit part of MVC.&amp;#160; The MVC pattern is very amendable to TDD however, and thus the association.&amp;#160; I generally support testable code even if there are no tests around the code.&amp;#160; Testable code is much easier to maintain, enhance, refractor, and replace.&amp;#160; I don&amp;#39;t find the process of test-first development helpful, but I do write tests in the same session as the code when I know I&amp;#39;m writing some critical piece of functionality that needs to survive multiple versions of the software.&amp;#160; As Hanselman noted, I&amp;#39;m like the &amp;quot;person who goes to church on Easter and Christmas&amp;quot; and I&amp;#39;m sometimes looked down upon by the congregation who attend weekly.&amp;#160; I&amp;#39;m okay with this, but I have some reservations with MVC as a framework for TDD.&lt;/p&gt;  &lt;p&gt;To say you cannot test WebForms is a strawman argument; there is no trouble in separating the Model and testing it thoroughly.&amp;#160; Depending on how you go about it, you can also separate the Controllers and test them - I generally have very simple Controllers that pass user input into the Model as is, so testing the Controller is not that important to me.&amp;#160; Testing the View in WebForms is very difficult - and this isn&amp;#39;t specific to WebForms.&amp;#160; My objection to claiming MVC has testable Views is the implied definition of testing.&amp;#160; Verifying the output HTML of a View is not helpful at all - it&amp;#39;s just string comparison.&amp;#160;&amp;#160; I want to write tests like Asset.JavascriptRunsOnSafariMac() and Assert.IE8RendersSameAsFireFox3().&amp;#160; If MVC could do that, then I would be switching to it today!&lt;/p&gt;  &lt;p&gt;WebForms provides a very robust SiteMapProvider interface that makes it easy to clean up urls of dynamic content.&amp;#160; Global.asax can be using to control routing of requests (in fact this is how MVC does it as well).&amp;#160; The biggest problem I&amp;#39;ve had here isn&amp;#39;t WebForms fault, but IIS6&amp;#39;s inability to allow ASP.NET to handle requests without an ASP.NET extension in them: this is solved in IIS7.&lt;/p&gt;  &lt;p&gt;You can get fine grain control of HTML in WebForms, ever with just the stock controls.&amp;#160; There is also an entire collection of HTML server controls to match HTML tags to make it easy to generate HTML from code (I hate seeing tags hardcoded in source file, feels dirty and hackish).&amp;#160; About the one thing that is hard to do in WebForms I deal with somewhat often is controlling the client side ID&amp;#39;s, which can become quite long and fugly looking.&amp;#160; For CSS you can just assign a class name instead of using ID references (and there aren&amp;#39;t many places I&amp;#39;m using CSS IDs except for layout divs that aren&amp;#39;t coming from ASP.NET controls anyway).&amp;#160; Javascript is trickier; you need to inject a reference of Control.ClientID on the server in the client script, and the need is much more common than with CSS.&amp;#160; If you have an external JavaScript file this can get worse, but I believe that an external JS method should take the ID of the control they work with as a parameter making it easier to read the external file without the need to reference the aspx code.&amp;#160; At the end of the day however, I&amp;#39;m not willing to throw the &amp;quot;baby out with the bath water&amp;quot; and will lean more on Microsoft to fix this issue in WebForms rather than jump to MVC.&lt;/p&gt;  &lt;p&gt;The last reason for MVC I mentioned, being closer to the http protocol and its stateless nature, I simply don&amp;#39;t grok.&amp;#160; Any application with a basic level of user interaction will need to mask the http protocol&amp;#39;s implementation details to provide a positive user experience.&amp;#160; Web programmers of all frameworks and languages have realized there are only a few methods to solve this problem; cookies, url parameters, and hidden fields.&amp;#160; Any state solution will involve one or all of these - even if state is stored on the server&amp;#39;s side.&amp;#160; WebForms supports all of these methods, and you can disable things like ViewState (hidden fields) if desired.&amp;#160; (I am aware there is also ControlState that will be still emitted if ViewState is disabled, but I&amp;#39;m willing to say that if these few bytes are an impact you are working on an edge case).&lt;/p&gt;  &lt;p&gt;I&amp;#39;m not here to bash ASP.NET MVC - to the contrary I&amp;#39;m here to help by outlining the faults in the current arguments for MVC.&amp;#160; If MVC is defined by the features in or not in WebForms, then it&amp;#39;s going to be hard for those deep into WebForms to see value in MVC.&amp;#160; It becomes a song of &amp;quot;anything you can do, I can do better (no you can&amp;#39;t, yes I can)&amp;quot; and will deadlock when neither side is listening to the other.&amp;#160; ASP.NET MVC need to be defined without claiming faults in WebForms, because that only says use MVC because WebForms is broken - leading one to say, &amp;quot;why not just fix WebForms?&amp;quot;&lt;/p&gt;  &lt;p&gt;I wish I could end here with a new explanation of ASP.MVC meeting the requirements I&amp;#39;ve just stated, but I&amp;#39;m afraid I can&amp;#39;t.&amp;#160; This is a fault with me, and not the MVC framework - I&amp;#39;m too close and deep into WebForms to see a need for MVC I can&amp;#39;t fill already.&amp;#160; It&amp;#39;s my hope and request that instead of seeking to pick apart this post, the supporters of MVC come out to define MVC without attaching that definition to the perceived faults (for that&amp;#39;s the minefield) of WebForms.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=41448" width="1" height="1"&gt;</description><category domain="http://devlicio.us/blogs/vinull/archive/tags/Featured/default.aspx">Featured</category><category domain="http://devlicio.us/blogs/vinull/archive/tags/opinion/default.aspx">opinion</category><category domain="http://devlicio.us/blogs/vinull/archive/tags/mvc/default.aspx">mvc</category></item></channel></rss>