I was looking through the searches on this site trying to think of what to post about today, and i noticed that, surprisingly to me one of the top searches has consistently been for information on the model-view-controller (MVC) design pattern. Maybe I shouldn’t be surprised though as this is a pattern that Apple often follows in their libraries, and examples, and is mentioned quite frequently.
A few months ago I posted a video where I gave a rudimentary explanation of MVC, and a method for coming up with some possible class names when developing an app.
You can see this video here:
In summary, MVC is simply this:
A design pattern in which the model (any data in your program), the view (what the user sees), and the controller (a layer that handles all interaction between the view and model) are separated in such a manner that modifying either the view or model component of your program has no effect on one another.
The purpose is that later on you may need to change your programs view, and by programming things in this matter you will not have to modify your programs model. Say for instance Apple comes out with an iPad for which the view is programmed somewhat differently than on the iPhone, but you would like to
Now I received some messages after making the video above, some thanking me for making the concept of MVC sound so simple, and others telling me that I had confused them, and wondering how I could understand any of this stuff.
Well, don’t fret.. I’ve seen arguments all over the place as to what components should be classified in the model, the view, or the controller, and I’ve even seen accomplished "guru authors" mess things up when explaining what goes where, just keep in mind that the key idea here is that you can modify one of these key areas without completely wrecking another key area of your program, and leave the rants to the wannabe coders who like to argue about what exactly what fits what acronym, and MVC is often their target.