Monday, May 28, 2012

MVC - Introduction


Welcome. This is my first blog on Model View Controller (MVC). I am blogging about it because I love programming in MVC so hopefully you will learn from my experiences. I also maintain a blog on Building Information Modelling (BIM) called BIM Manager, as aside from programming I have a passion for Architecture also. I think this puts me in a very small but growing group of individuals.

Through a series of posts over the next few months I plan to cover topics on MVC, Databases, Entity Frameworks (stuff that connects MVC and databases) and jQuery (very smart JavaScript). I may wander into other interesting MVC and Object Oriented related stuff but will try to keep focused.


MVC stands for Model View Controller. MVC is a bit of a buzz word at the moment as it is recently increasing in popularity. But what is MVC?

MVC is a pattern based framework for building applications. Software systems use MVC to basically put manners on code by ensuring code abides by strict rules. With a little bit of time and some coffee, you could even develop your own MVC pattern but there are plenty of good patterns out there and life is about more than just programming. MVC is a pattern or a set of rules. Applications such as Ruby on Rails, iOS and ASP.NET MVC now have some very well defined rules for how MVC code is structured. MVC is not new as it has been around since 1979 and was originally named Thing-Model-View-Editor.You will now find MVC in many applications both for the web and desktop. For example, if you plan to write an app for an iPhone, you will need to use MVC. Many organisations are using MVC to simplify very complex applications and websites.

I primarily develop web applications and also dabble in desktop and iPhone development. I started web programming in VB and Classic ASP which for a long time got a lot of productive programming done. When I switched to ASP.Net, I had great hope that it would remove some of the repetition involved in scripting while promoting reuse through Object Oriented programming. The reality was not so good. ASP.NET added so much baggage trying to make web sites work like windows based applications, that I soon was fed up and used it sparingly. I looked at a few bolt-on applications such as Devexpress for Visual Studio to automate some tasks but it was still clunky. The viewstate functionality of ASP.NET especially annoyed me, this wasn't web development any more.

I started to look at Ruby on Rails which has led the way in web MVC programming and then came across ASP.NET MVC which was still at the early stages of development. I found the Model View Controller a bit puzzling at first, but soon things started to click as I realised I was relearning the basics of HTML again. I was also starting to learn iOS programming for the iPhone/iPad online from Stanford University and was surprised that MVC was being used here also. Ruby on Rails is a great programming environment and credit must be given to David Heinemier Hansson for having the insight to bring MVC to the web. HTML has recently evolved to version 5 is now changing the web again with the introduction of media related functions that were long needed. It is exciting times indeed to be looking at MVC.

I opted to develop in ASP.NET MVC mostly because I was familiar with Microsoft applications and also because I program for AutoCAD and Revit which until recently were solely Windows based. I switched most of my programming tC# when I started MVC as most of the material and samples on the web were C#. VB will work just as well and there are websites that will convert VB to C# and vice versa.

Onward and Upward

Slightly convinced? Try MVC out, you won't regret it. It is suitable for beginners or experienced programmers alike.

I would recommend learning some basics of HTML first. W3Schools and HTML Goodies are excellent web sites to get you started on basic HTML and JavaScript. Many tutorials and books start with the Model or the View but my first meat and bones post will look at the HTML form. Yes, this is the basic HTML form that has been around since the beginning of HTML. MVC relies surprisingly heavily on HTML forms. I will include code with each post and build up to a useful everyday application.


No comments:

Post a Comment

Note: Only a member of this blog may post a comment.