The Model View Controller concept is expressed all over the place as an important thing to keep in mind when developing an application. But when developing applications, I struggle to distinguish whether or not I'm using the MVC model and whether or not that is hurting my application. Why is the MVC concept important in application development and how does it help developers make better programs?
4 Answers
Well, like doing many things in life, it always helpful to be well organized. Models, Views and Controllers are distinctly different pieces of code that helps to provide different functions to your overall project. Because of that, they are kept separate and organized.
Imagine if you were designing a program. You wouldn't put all your code into one function, would you? No, you would divide them up into separate smaller functions that solve very specific tasks. Likewise, as programmers, we're constantly looking for ways to separate and divide our large applications to smaller bits of pieces. One of these organization design patterns is MVC, where, the model (the data) exists in one section, the view (the UI) exist in one section, and the controller (logic) exists in another section.
What problems does this solve? Well, just as how having separated functions solve the problems of readability, modularity, and coupling, so does MVC. Say if you wanted to change a piece of code, you can tackle it in a smaller subset that is more or less isolated from the larger piece of code. This allows you to add, modify or remove code more effeciently and logically. It also helps in testing, since similar code is sectioned into groups, you may be able to have better coverage of your tests cases. Also very important is that you end up writing a lot less code.
Hope this helps.

- 600
- 2
- 6
- 14
Have you heard of "separation of concerns"? MVC, in simple terms, is an architecture that allows different parts of a system to be loosely coupled (or separated). Views are typically dumb and display data and take user actions. Models represent the data and domain logic in your system. And controllers liaise between the View and the Model, often controlling flow. There are loads of variants on the original Smalltalk MVC pattern and nowadays it seems like every framework is MVC.
The advantages are it makes your code less fragile, easier to understand and change and easier to unit test. All because it is separated into different parts.
A good example is that I recently changed job and started working on a new project in PHP (I come from .NET background). The learning curve was much easier because we use an MVC framework. Because I already knew the pattern, I knew where everything "was", as such, and how the system was put together.
http://en.wikipedia.org/wiki/Model–view–controller https://gamedev.stackexchange.com/questions/5372/mvc-like-compartmentalization-in-games

- 1
- 1

- 14,253
- 6
- 54
- 63
That's a question you'll understand once you've experienced a few software development projects...
Most prominently, it separates code into logical areas. UI code is kept in the UI (View), business logic is kept in the Controller, and objects are kept in the Model. If you need to update the UI, create a different UI (such as web interface), create web services or what not, then you don't need to spend forever and a day dissecting a tangled mash of incomprehensible code. You can also get different member of a team to specialise in a certain area, such as the UI or model, and this can lead to more robust code or perhaps allow a junior developed to work on something less complicated than the whole picture.
Here's an old post from pre-MVC Framework days when I worked with the Microsoft Web Client Software Factory (based on MVC... or MVPC... or whatever):

- 2,183
- 4
- 32
- 48
You are separating software components and creating a design that is loosely coupled. This will allow for easier maintenance, easier to read and shorter code, flexibility, and expand-ability. Many things follow this design patter (websites, mobile apps, ect.)
I can promise you learning it is well worth your time. I would suggest jumping in and starting with something simple like (CodeIgniter, PHPBlueprint) just to get your feet wet and see an MVC work.
A good book to checkout would be Head First Design Patterns.

- 5,170
- 7
- 40
- 64