tag:blogger.com,1999:blog-13221527.post6918651771842174304..comments2023-10-26T05:42:47.148-04:00Comments on Development tips: ASP.NET: MVC Framework vs Web Forms FrameworkDennis Gorelikhttp://www.blogger.com/profile/17700219093521377626noreply@blogger.comBlogger6125tag:blogger.com,1999:blog-13221527.post-90275949368441795982011-03-05T05:42:54.335-05:002011-03-05T05:42:54.335-05:00In my opinion, the question is becoming blurred wi...In my opinion, the question is becoming blurred with a lot of the cool features of MVC making their way into Webforms. ASP.NET 4.0 added URL Routing, reduced ViewState, and greater control of the HTML mark-up produced by many ASP.NET controls, now the next version of Webforms will incorporate many more MVC features into Webforms. <a href="http://blog.evonet.com.au/post/2011/03/05/What%E2%80%99s-coming-in-the-next-version-of-ASPNET-Webforms.aspx" rel="nofollow">What’s coming in the next version of ASP.NET Webforms?</a>Bartekhttp://blog.evonet.com.aunoreply@blogger.comtag:blogger.com,1999:blog-13221527.post-62858635086193740512010-01-26T13:04:39.628-05:002010-01-26T13:04:39.628-05:00Yes, you are missing something. The lines would be...Yes, you are missing something. The lines would be divided equally and would pretty much be the same as in your example (hence a way to simple example to show anything). Jeremy added that model because it is good practice to call a method with one object instead of a number of parameters. But as you didn't bind it to a model in your example (you should) I didn't do that in my example. So instead of taking that model as a parameter I would just take a string.<br /><br />But lets say we need a few more parameters and we need to bind that to some kind of model. In mvc you create that model, create input fields for each of the properties and take that as a parameter to the action. While in webforms you have to create the model (as in mvc), create inputs for each field and then manually bind it in your code behind.<br /><br />Webforms will always require you yo write more lines of code.Mattias Jakobssonhttps://www.blogger.com/profile/12533853821389122722noreply@blogger.comtag:blogger.com,1999:blog-13221527.post-6059144492242213722010-01-26T12:50:15.637-05:002010-01-26T12:50:15.637-05:00Mattias,
What would these 5 MVC lines be?
Jeremy ...Mattias,<br /><br />What would these 5 MVC lines be?<br /><a href="http://codebetter.com/blogs/karlseguin/archive/2010/01/22/the-webforms-rant.aspx" rel="nofollow">Jeremy D. Miller gave this answer</a>:<br />===<br />- 1 line of ASPX code for textbox<br />- 1 line of ASPX code for Save button / submit button<br />- 3 lines of controller code:<br />void Save(InputModel model) {<br />BusinessLayer.Save(model.Text);<br />}<br />===<br />But he didn't address where InputModel declaration come from.<br /><br />It looks like that declaring InputModel would take additional lines of code (which bring the total above number of lines needed in Web Forms).<br /><br />Am I missing something here?Dennis Gorelikhttps://www.blogger.com/profile/17700219093521377626noreply@blogger.comtag:blogger.com,1999:blog-13221527.post-5261241037124880312010-01-26T12:32:04.181-05:002010-01-26T12:32:04.181-05:00That example is way to simple. You have to write t...That example is way to simple. You have to write the exact same number of lines. How many more lines would you have to write with webforms if you add 3 more fields? The answer in mvc is 3. If you want to map it to some class the answer is still 3 (excluding the class itself that will look the same in webforms).Mattias Jakobssonhttps://www.blogger.com/profile/12533853821389122722noreply@blogger.comtag:blogger.com,1999:blog-13221527.post-24672184661738458402010-01-26T12:28:18.582-05:002010-01-26T12:28:18.582-05:00Mattias,
How many lines of code would developer h...Mattias,<br /><br />How many lines of code would developer have to write (typing or using designer) in my example above in MVC?<br />Web Forms -- 5 lines.Dennis Gorelikhttps://www.blogger.com/profile/17700219093521377626noreply@blogger.comtag:blogger.com,1999:blog-13221527.post-53965368830336460132010-01-26T12:21:33.913-05:002010-01-26T12:21:33.913-05:00If you say that asp.net mvc requires more lines of...If you say that asp.net mvc requires more lines of code then webforms you have simply not tried mvc or you have done it very wrong. Asp.net mvc have always (from the first release) and will always require less code then webforms. The reason for this is that you don't have to deal with form posts and mapping to your domain model. So if loc is the best metric of project complexity then use asp.net mvc (or just about any other framework available) instead of webforms.Mattias Jakobssonhttps://www.blogger.com/profile/12533853821389122722noreply@blogger.com