I am trying to reduce/eliminate "magic strings" from my MVC3 project and was wondering which approach would be better:
use MvcFutures and do something like:
var title = "Create New Customer"; Html.ActionLink (c => c.Create(), title , new { @class = "button", title = title });
use T4MVC
Which option is more flexible, more performant, easier when refactoring, etc, etc?
Thoughts?
T4MVC, no contest. It let's you reference views and controller actions using a hierarchy of (code-generated) nested classes and properties. This approach has several benefits - available options can easily be discovered, and it provides the best possible performance (certainly a big win compared to the lambda-approach for strong typing).
It's also very easy to write your own extensions that use T4MVC's dummy ActionResult class. For instance, I have some ActionImage helpers that extract the necessary routing information to generate the resulting markup.
The only downside to T4MVC is that you need to keep the generated code file up to date. You can do this by keeping the .tt file open or by installing an extension that will run .tt files automatically (e.g. Chirpy).