Monday, May 9, 2011

Introducing yourself to ASP.NET MVC

I've been interested in this technology from the first time a heard about it and I am very excited about it. Unfortunately, I haven't got a chance to work with it professional, yet, But still I tried building some application in my spare time and feel very keen on mastering my skills.

Getting started with ASP.NET MVC can be really frustrated in the first couple of days. Especially, for developers that have years of experience with Web Forms. As I already showed in my previous post, building a simple application is really easy.

What confused me the first time was the 'Convention over Configuration' philosophy. This can give you the feeling that lots of things happen by magic. If you are a control freak, you can feel really vulnerable at first glance.

Web Forms concept is to mimic the Win Forms developing style. ASP.NET MVC on the other side is something brand new:
  • No PostBack is used
  • The web pages are no longer physical source code files.
  • Events usage is cut to minimum

When you try building a web site using some NuGet package you think that even more magic applied and things can become really messy. Well, this is the challenge that every new framework brings. A steep learning curve, but also a different angle to look at programming. Even if you not use it in your every day work - it will enrich your mindset and probably help you build better designs and cleaner code.

Usually you don't pay attention to those details until you are stuck with a problem that you have no idea where it came from. Not knowing how the things happen from inside will be you worst enemy when debugging your application and setting your environment.

What helped me is a book called Professional ASP.NET MVC 3.0. It's great, it's written by the people who invented the framework. After the first two chapters you will be able to write your own application. With the rest of the book you will gain deep understanding of the lifecycle of every MVC application. You will know what are View, Controllers and Models, how are defined, how can be extended and how can they do your job. There are lots of examples and some more sophisticated scenarios are discussed. Lots of good insights are waiting there, so ... Enjoy!