views:

801

answers:

5

Using magic strings in C# really unsettles me, so I'm thinking of using the MVC Futures library.

Are there any reasons why I might not want to do this, or any gotchas I should be aware of?

+3  A: 

I've been using it for about 1 month now and really like it. For instance, I love the new strongly typed Html helpers, it sure beats using magic strings:

<%= Html.TextBoxFor(m => m.User.FirstName)%>

According to the MVC roadmap, this feature will be part of MVC 2, but even if it shouldn't, I still have the futures source code so I can use this helper implementation as a last resort.

Adrian Grigore
+3  A: 

The risks of using features from ASP.NET MVC Futures are

  • they are considered not polished enough to ship as part of the core framework, so could introduce some bugs;
  • the Microsoft team may not merge them all into the next version of the core ASP.NET MVC package or significantly change their behaviour.
Alexander Prokofyev
+3  A: 

I think it has some features that really should be in the MVC library but I would stay away from the strongly-typed action links. That can get extremely expensive on the CPU potentiall9y adding SECONDS (not MS) to your page render time.

http://www.chadmoran.com/blog/2009/4/23/optimizing-url-generation-in-aspnet-mvc-part-2.html

One of the functions available in MVC futures I often find myself using is RenderAction since it is the only way to worka around partial output caching.

Chad Moran
"adding SECONDS... to your page render time" * if you are rendering ten thousand links at a time.
StriplingWarrior
+1  A: 

Not so sure about the futures, but I would highly recommend the Mvccontrib library which depends on some bits in the futures.

Wyatt Barnett
+4  A: 

First of all, just because it's a string, doesn't make it a "magic" string. Second of all, I would recommend looking at the T4MVC templates David Ebbo writes about here: http://blogs.msdn.com/davidebb/archive/2009/06/17/a-new-and-improved-asp-net-mvc-t4-template.aspx.

The benefit of this approach is by using code generation, you get strong typing everywhere and it doesn't require compiling expressions which can hurt performance.

Haacked