I’ve recently started writing MVC 3 apps and I was wondering what approaches you guys took to crafting the GUI.
Obviously there is no design view so do use a WYSIWYG tool like Dreamweaver or just write the app and hand craft the CSS styling at the end?
Any thoughts/experiences appreciated.
I have always written the code myself. I am a big believer in Donald Knuth’s old saying about WYSIWYG = What you see is all you will ever get. One of the big problems I have with WYSIWYG editors is that they tend to make a bit of a mess behind the scenes, especially with styles. You get the result you are after, but in my experience handcrafting the pages and styles yourself results in a product which is far superior in maintenability and performance.
As for the coding of the page itself, I must say that I recently made the move to Razor, and am very impressed indeed. I believe that this is the single best thing you can do to make ASP.NET page coding easier. The syntax is easy to learn and far cleaner than the old <% syntax used in ASP.NET.
A quick thing to note note about Razor in case you haven’t used it yet is that certain bits of code like this…
…will not work when transformed into Razor syntax, because Razor actually parses your code. Here, Razor will complain because the div element isn’t closed.
The solution to such problems is to create variables and in-page HTML helpers with the
@helpersyntax to manage logically-created blocks of code. For me this is a huge improvement to ASP.NET, both in readability and in bug reduction. I construct my complex components beforehand and then plug them in to an HTML frame. This makes the structure of the page more readable and much easier to debug.So, to get back to your question: For me, the best way to develop MVC apps is to write the pages by hand using Razor syntax and to do your own CSS. I find intellisense to be pretty good, especially in VS2012 for all things non-JavaScript related (including CSS), so if you don’t have a ton of raw web development experience it should help you through most of the rough patches and will teach you a lot at the same time.