tags:

views:

71

answers:

2

Tomorrow I will kick off a new project, a line of business application for a client and I have decided to build with asp.net mvc. I am an experienced webforms developer, also silverlight lately but this will be my first real mvc app. I have watched some videos and get the core concepts enough that I have tossed together some proof of concept MVC work so I am not looking for the trivial 'there is no postback' kind of answer here.

What I want to know is, what if any things do you know now you wish you knew when starting out in MVC? What should I avoid? What should I make sure to do?

+2  A: 

A few tips from the top of my head.

  • Make sure to use a IOC-container. Makes my life much easier when the project turns complex and helps a lot with unit testing.
  • Understand the concept of view models. And try to only send one model to each view.
  • Do unit testing. If you are not into this already, now is a good time to start. MVC makes it a lot easier than webforms.
  • Take a look at alternative viewengines. I think spark is the best at the moment, but there are a lot of others good alternatives. At least use some time to take an informed decision.
  • Make your view as easy as possible. If you need more code than a loop in your views, try to make a helper.
  • Learn JQuery and Javascript.

After using MVC every day for about 2 years. I still learn new things and better ways to do things, so keep looking for better solutions. I think MVC is a lot more fun than Webforms and I really do hope never to work with Winforms again.

Good luck!

gautema
I think if you could expand on the 'better way to do things', this may address the question more relevantly.
Ahmad
My list includes a lot of the mayor things I have learned. The things I still learn how to do things better is mostly in how to use the view models and the IOC-container smarter.
gautema
+1  A: 

One of the "negatives" mentioned quite frequently about MVC is the tag-soup that can become quite unwieldy and ugly. I good way to combat this is to move your view based logic into a ViewModel with any logic moved into there. Eg. You could have..

<div><%= Model.PluralizeUserCount %></div>

Instead of..

<% if(Model.Users.Count == 0) {%>
<div>There are no users in the system.</div>
<%} else { %>
<div>There are <%=Model.Users.Count.ToString() %> users in the sytem.</div>
<%} %>

Much neater!

Matt