One idea for ASP.NET MVC… strong typed View names

1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 5 out of 5)
Loading ... Loading ...

I really hate magic numbers, strings, etc… In all my projects I really try to avoid them as much as possible.

Wouldn’t it be nice if MS (or we as a community if they don’t… I can think of several ways to do it) would generate a strongly typed class called Views which contains the name of each View in the application, so like:

- View.Home
- View.About
- View.Contact
- VIew.Products


and instead of referencing by magic string:

mvc-strongtype1

something like this (of course implemented all over, not only in ActionLink):

mvc-strongtype2

(Resharper has put it in red… disregard that coloring issue)

Arguably a small detail… but as I said, not too hard to implement and… I REALLY hate magic strings :)


What do you think?


Filed under: ASP.NET MVC
Written on: 12 Dec 2007 ·

kick it on DotNetKicks.com

Leave a Reply