Tuesday, December 22, 2009

Model View Controller (MVC)

My family should now be saying, “Yea! Another blog post about techie stuff!” Yep, this is another one of those, but this one goes past techie. It’s for programmers!

The MVC is a way of separating and decoupling the three major pieces of a program and is done usually through the use of interfaces. You have the Models, which are the classes the data is “stored” in. These models are also the base level that programmers start. They are how your data is defined. The View is exactly what it sounds like, what the user is going to view on the screen. The Controller is the brains of the outfit. It is where the program starts moving and shaking and spitting out data that the user didn’t know they had.

That is a very basic way of describing the MVC. My definition goes a little beyond that. If you really want to decouple the objects in your project, you need to have to Controllers, View Controller and the Data Controller.

To me this is the only way to keep the views from really knowing how the data is handled. Some will say that you only need one Controller and it can handle the views as well as the data or it’s the Views job to handle how the program looks and feels; but if we are going to break things down, why not break them down into Single Responsibility objects ? The View Controller handles the views and the behavior of the views and the Data Controller handles how the data is presented and manipulated.

So I guess I have my own philosophy of MVDCVC (Model View Data Controller View Controller). Really not sure if I should put this out there because it’s not a refined way to look at it, but, here you go. Let me know what you think.

No comments:

Post a Comment