Monday, March 10, 2008

ASP.NET MVC - Preview 2 Thoughts

I said previously that I was excited for this release.  Ultimately I didn’t see much worth blogging about.  Some features are a step in the right direction, some (I think) were a step back.

I’m currently upgrade Code Camp Server to Preview 2 and hit about 80 errors which I had to go in and resolve.  My initial thoughts:

  • I think the HttpContextBase is a bad idea.  Yes I understand the desire to not introduce breaking changes.  But I think that the people that will be using ASP.NET MVC will be congnizant of this and code appropriately.  Interfaces are much easier to depend work with while testing, and I’d rather just use those.  Hey, couldn’t they give us both, and framework providers could choose?
  • what’s up with the OnActionExecuting, OnActionExecuted events?  These used to be OnPreAction, OnPostAction, which was much more readable (in my opinion) — seriously, put these back!  The new naming is not nearly as obvious to the glance.
  • Testing is still too cumbersome.  I think some good mocking-fu can mitigate this, but it’s a tough sell to people new to unit testing (and to mocking).  TempData should be implemented as an IDictionary on the controller, only to have a real TempData that depends on session state at runtime.  This would allow me to test that TempData works without having to mock session (which is not intuitive at all).
  • The Action filters are going to be where the goo lives.  This is how we will see some really productive & handy filters for performing actions such as requiring SSL, protecting an action from unauthenticated access, loading common data, etc.  Think of them as HttpModules for individual actions.

More to come, I’m sure…

 

 

Monday, March 10, 2008 3:46:45 PM (Central Standard Time, UTC-06:00)
Good feedback ben. I'll address #2. We changed the name in order to follow the .NET Framework Design guidelines. Since there's only two events, we thought this wouldn't cause much confusion. Here are the relevant guidelines.

 DO name events with a verb or a verb phrase.
Examples include Clicked, Painting, DroppedDown, and so on.
 DO give events names with a concept of before and after, using the present and past tense.
For example, a close event that is raised before a window is closed would be called Closing and one that is raised after the window is closed would be called Closed.
 DO NOT use “Before” or “After” prefixes or postfixes to indicate pre and post events.

For #3, I agree that testing is cumbersome and we'll improve it.
Tuesday, March 11, 2008 9:23:37 PM (Central Standard Time, UTC-06:00)
I personally don't like OnActionExecuting, OnActionExecuted. Pre/Post is much more readable.
Guidelines... Who cares if it makes things harder :-) Let's be honest :-)

And I think these guideline rules are applied to *.NET events* and mostly for UI. Pre/Post action is not really an event, but "notifier".
What about "notifiers" like these: Erroring, Errored; Paying, Payed; Browsing, Browsed etc.
Doesn't look very clear for me.

Erroring - - are we rasing an error?
Paying - are we paying just now? Not clear that we are going to pay AFTER this notifier.
Browsing - sounds like we are browsing now, but not going to do it.

Same with Painting - are we painting now or we are getting ready to do it?

And "ing" in English (correct me if I'm wrong) indicates regular or continuously performed action, definitive attempt to do something. Where "Pre" really shows it is just going to be executed before something.

Thursday, March 13, 2008 8:39:43 PM (Central Standard Time, UTC-06:00)
Yeah I agree. The Framework design _guidelines_ should be just that: Guidlines.

For most things I think it has generally solid advice, but in this case I challenge it.
Monday, March 31, 2008 8:06:05 PM (Central Standard Time, UTC-06:00)
OnActionExecuting ... OnActionExecuted. They match the LINQ to SQL convention for property events OnPropertyChanging ... OnPropertyChanged. OnPreProperty and OnPostProperty would not make sense
mario
Friday, April 04, 2008 6:07:52 AM (Central Standard Time, UTC-06:00)
To me, 'OnPostAction' reads like "on POST action", which sounds quite ambigious - could be mistaken for meaning a POST is made to an action, I guess. I like the new names much better :)

The rest I agree with, especially the point about the HttpContextBase class.
Thursday, May 01, 2008 4:09:10 PM (Central Standard Time, UTC-06:00)
OnBeforeAction, OnAfterAction?
Comments are closed.
Credit Card Consolidation - Car Insurance - Mortgages - Arizona Pools