On ASP.Net MVC (yes, again :-))
As you probably know by now, I have been working on an ASP.Net MVC project for the last two weeks. Based on that, I think that I can base a pretty good opinion about it.
Are you ready for it?
[insert significant pause here]
I like it.
Now, just to be clear. I like it not only in comparison to WebForms. I like it on its own. In other words, I don't consider the ASP.Net MVC to be a default choice if all you have is that or WebForms.
The pros of using an MVC framework are well known by now, so I wouldn't go blathering about that. ASP.Net MVC certainly hits a lot of those points. Another benefit that wasn't obvious to me was the default view engine, which uses the same WebForms editor. This means that we get intellisense. That was surprisingly nice to have.
Unfortunately, the WebForms view engine is also useless for any intermediate to advance scenarios, because it only allows you to render directly to the response, and doesn't allow you to capture the output of views and partials and process them further.
Another problem that I encountered with the framework is that, to someone who has been doing MVC for years, is it extremely non obvious at times. My default mode of learning is to dive into the code, and in general, this has been a successful way of doing things across many projects that I learned. I don't really like it that I run into brick walls along the way with ASP.Net MVC, but I should point out that my thinking about how things should work is based on my work with MonoRail, and it is likely affecting my expectation about the way the ASP.Net MVC behaves. Even so, there are several design decisions made there that I strongly disagree with.
The most problematic issue that I run into with the ASP.Net MVC during the last too weeks, and the reason that I don't consider the ASP.Net MVC vs. MonoRail to be a coin toss, is that a lot of the code is internal.
Now, I didn't actually went over the ASP.Net MVC source code. But I did tried to do things with it and was blocked several times because some of the things that I wanted to do are internal (IBuildManager comes to mind as a repeated example). The obsession with internal, and the resulting limitations of what I can do with the framework, is a huge problem for me in just about any Microsoft product. In this project, I explicitly didn't set out to create any complex site. I built a very trivial data driven CMS. Nevertheless, I hit a lot of those internal API, grr!
Most of those occur when trying to do anything interesting with the web forms view engine. There is enough friction using that that is it worth dropping it (web forms view engine) all together, even with the bonus of having intellisense in the views.
From the point of view of actual framework, I found it pleasant to work with for most of the time. And the extensions points that are open are very useful (OnActionExecuting, OnActionExecuted are good example of that). I think that in order to really get the benefits of the framework, I am going to have follow Jeremy Miller's footsteps and rip out all the thinks that I don't care about and replace them with a heavily opinionated and customized version.
The good news is that it is possible, and without too much problem.
Comments
I think the main problem of ASP.NET MVC is the WebViewFormEngine, which too tied to the underlying "legacy" webform model.
But the good thing is that you are not forced to use it.
Given your excellent abilty, when are we going to see a RhinoViewEngine? :)
Of course if you don't use it you loose the help of the intellisense.
I never looked at it: would it be theoretically possible to build an "intellisense provider" for custom languages to use inside Visual Studio?
Simone,
Take a look at Brail
I was planning to do it... together with NVelocity, NHaml, Spark: they are all going to be featured inside my book on ASP.NET MVC.
Btw: if you want a copy, just ask (in change of a review ;-))
AspView egine for Monorail has Intellisence support. Could be ported to ASP.NET MVC.
Arg. Not move MVC stuff. I'm so tired of hearing about it now. 23 RSS feeds and every morning 70% of it's MVC. It seems like all these people who like the MVC pattern, are the same people who couldn't write a decent WebForm app to begin with...
I'm gonna start unsubscribing from blogs.
Hey Ayende, what were you trying to do with IBuildManager. I believe that's internal because there's a different extensibility point. If I understand the scenario, I can look into whether there's a way to do it or not.
Why use this instead of Monorail, Brail, NVelocity, etc?
Yes I have to agree with your bit about too much use of internal (it's like herpes: once you use it, it never goes away).
I have to say that I've almost come to the point that I am going to start adovcating that the use of "internal" as an antipattern. Maybe i've been infected by smalltalk after all this time :)
Phil,
Trying to get an instance of a Page so I could mess around in its Control hierarchy.
Basically, I wanted to apply a cross cutting UI concern across the entire site. That required me to be able to control the way Pages are created.
woohoo, roll on "ASP.NET Ayende"! (or should that be "MVC.Ayende"?)
=)
Internal is the devil. It's one of the most horrible inventions in the history of comp sci. Please ban it in it's entirety!
Oh, and while I'm at it sealed isn't no better. Anybody who seals a class needs to be beaten repeatedly with a wet noodle.
Yes,
M$oft has an obsesion with internal. See also VSDB SQL parsers. etc.
Solution:
CECIL + add InternalsVisibleTo your framework + no need to recompile the code.
So ASP.Net MVC is like MonoRail only not as good but with intellisense. I'll never understand why Microsoft bothered to create it, and I'll never understand why people are excited about it. I guess it's just not for me.
Has anybody tried Spring.Net MVC? I love the rest of the Spring framework but haven't really gotten to get to this part of Spring.Net. Any opinions?
I wanted to mention that you can render partials in several ways. There is a good example of a controller extenstion that renders to a string. I blogged about it www.vitaminzproductions.com/.../renderusercontr...
The MVC team responded to my scathing blog post: www.vitaminzproductions.com/.../aspnet-beta-is-... bu indicating that you can use a different view engine for partials and pass a string writer so that you can then manipulate the output. I haven't discovered how to do that.
I had been using MOnorail for some time and absolutely loved it. Microsoft created their slant on MVC, IMO, because there are alot of shops that would rather use supported software than innovate with open source. It sucks but its true. I've worked for a few of those. I embraced MVC because quite a few respected Monorail fans were impressed by the early demos. I love it. It takes all the harship out of web forms.... well, almost all.
I'd like to see more support for alternate view engines and more public adoption. For some technical leads, they have to weigh the cost of educating new developers against the eventual gains that can be made.
I'm glad to see mIcrosoft do something well. I agree with you that the Internal nonesense is frustrating. I'm very excited to see such quality open source communities and individuals (you rock ayende) converging around common interests and a passion for quality software and beautiful design.
Comment preview