thoughts on coding

December 16, 2009

Reaction to Dino’s comparism WebForms and MVC

Filed under: ASP.NET MVC — Tags: , — Frantisek @ 5:27 pm

I visited TechEd in Berlin this year with my colleagues and we had a discussion which web technology will we use in the big corporate env in near future. We worked with WebForms for several years and we (in Prague) did several projects with ASP.NET MVC. I muys say, I’m big fan of MVC because it’s finally trying to enables the developers to use the basic development principals like SoC, TDD, IoC/DI which has bug impacts on the code quality, application performance and maintenance! Personally, I think, MVC will be used in majority of the web apps developed in near future on .NET platform.

Anyway, my colleague spent some time searching the comparism and sent me a link from Dino Esposito where the author compares WebForms and ASP.NET MVC. I discussed this article with the colleagues who developed the web apps on MVC and we were really dissapointed with Dino’s article. I knew Dino as the author of ASP.NET web forms articles and based on the article he published on MSDN! about MVC I think, he was he paid by M$ to popularize WebForms over MVC with such junior-level facts or I dont know.

The problem is , Dino is quite know person and it takes a time to explain the people why this his article is so junior-level article selling WebForms. I took me really much time to explain people what was hidden in his article I’dlike to share it with you now.

Dino’s facts:

  • Web Forms allows you to learn as you go.

What? What does it mean? What weak fact is it? Did not ASP.NET MVC allow you to do the same? Come’on man, give me a break! To do the things correcntly (with the focus on QA, performance, etc) is hard! I dont want to use drag’n’drop M$ school, I dont want to use datasets or SQL data source with SQL in the aspx!  

  • Viewstate can be controlled or disabled.

Correctly disable complete viewstate/control state is quite hard work.

  • Web Forms was designed to abstract the Web machinery.

Is is advantage? I think, not! When devleoping apps on WEbForms I had to explain several times to the devleopers where the events occures (client or server?), etc. This abstraction hides many facts which web developers should be aware of!

Dino is presenting that you dont need to know HTML, CSS and JS to do the web forms. That’s the shame. I would compare it to the automechanic who doesn’t have knowledge how to fix the cars but he is fixing them. The result is bad quality. We, web developers, have to know HTML, CSS, JS and we need to have full control over them!

It’s funny how Dino’s presenting the comparism of the life cycles of MVC and WebForms. The page lifecycle is really hard to remember! It’s really hard to learn as you go! It would be fair to compare basic but full page lifecycles and you would see the difference. MVC is much simpler => much faster!

Honestly, I see the following main differences between WebForms and MVC:

  • MVC is more easy to understand and learn. After few years of the web forms developemnt I need to have the page lifecycle painted in the front of me to correctly do the things I want to achieve. It’s heavy and complicated! And I dont mention Viewstate/Controlstate nightmare! I think, MVC is much cleaner approach for the developers.
  • MVC was based in its core to follow TDD approach and it’s cool! Using WebForms it’s harder but you can use i.e. WCSF with MVP pattern.
  • MVC is much faster!  In MVC there is no needed overhead with pagelifecycle, etc. It’s very clear approach and it’s much faster!

There are 2 core requirements from our customers: I need to have good SW quality and I want to have fast application. MVC wins!

I think, MVC could miss the UI components. But this is not true because there are plenty of jQuery components which are free to use, you just need to set them the data and UI layout.

I visited Dino’s blog and he is presenting ASP.NET MVC and say that version 4.0 of ASP.NET is the dead-end! Hm, strange. On one side he is writing how web forms are cool and then next day he is presenting about MVC and he wants to write a book about MVC. No, thanks! There are better professionals than you who wrote about MVC (MVC in action, MVC unleashed).

At the end of the day I’d be very happy if people baid by M$ would inform/present topics more correctly and fairly. I take really too much time to explain other colleagues where the real benefits of the presented technologies are!

Advertisements

March 11, 2009

TT template for MVC Grid with ordering and paging

Filed under: .NET, ASP.NET MVC, MVCContrib, TextTemplate — Tags: , , — Frantisek @ 1:35 pm

In my previous posts I wrote about my extensions to MVCContrib grid like paging and ordering.

It’s tedious work to create the pages with the grid and define all the columns by hand. As you know from MVC RC1 it’s possible to use the TT templates to gerenate the views. I found a TT template fofr MVC Grid somewhere on the web and I extended it to generate the views using my extentions for ordering an paging.

Here is a screenshot from the template:

mvccontrib

When you copy such template to the folder:

C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\ItemTemplates\CSharp\Web\MVC\CodeTemplates\AddView

then you will be able to use it in the dialog:

mvc_addview

and here is the result:

mvc_addview_result

While generating the view using the entities which are derived from some base class which is not in the same assembly as the entity, you can get the exception “Could not load type …”. You need to copy the base assembly to the location “C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies\\” and then it starts to work properly.

Using such template mechanism the developer can create the lists, details, etc. very quickly . The heart of the whole process is TT template. Just briefly, there is quite exhaustive blog here regarding TT templates.

The template can be found here

Blog at WordPress.com.