<p>Model view controller (MVC) is a very useful and popular design pattern.  If you&rsquo;re writing software, you should know it. Unfortunately it&rsquo;s also  one of the hardest to truly understand. In this article I will provide  what I think is the simplest explanation of MVC, and why you should use  it.</p>
<h4>What is Model View Controller (MVC)?</h4>
<p>In a typical application you will find these three fundamental parts:</p>
<ul>
<li>Data (Model)</li>
<li>An interface to view and modify the data (View)</li>
<li>Operations that can be performed on the data (Controller)</li>
</ul>
<p><img src=\"/edesk/images/mvc-fig.jpg\" alt=\"\" width=\"405\" height=\"232\" /></p>
<p>The MVC pattern, in a nutshell, is this:</p>
<ol>
<li>The <strong>model</strong> represents the data, and does nothing else. The model does NOT depend on the controller or the view.</li>
<li>The <strong>view</strong> displays the model data, and sends user actions (e.g. button clicks) to the controller. The view can: <ol>
<li>be independent of both the model and the controller; or</li>
<li>actually <em>be</em> the controller, and therefor depend on the model.</li>
</ol> </li>
<li>The <strong>controller</strong> provides model data to the view, and  interprets user actions such as button clicks. The controller depends  on the view and the model. In some cases, the controller and the view  are the same object.</li>
</ol>
<h4>What is the advantage of MVC?</h4>
<p>Unnecessary complexity is the devil of software development.  Complexity leads to software that is buggy, and expensive to maintain.  The easiest way to make code overly complex is to put dependencies  everywhere. Conversely, removing unnecessary dependencies makes  delightful code that is less buggy and easier to maintain because it is <strong>reusable without modification</strong>. You can happily reuse old, stable code without introducing new bugs into it.</p>
<p>The primary advantage of the MVC design pattern is this:</p>
<blockquote>
<p><strong>MVC makes model classes reusable without modification.</strong></p>
</blockquote>
<p>The purpose of the controller is to remove the view dependency from  the model. By removing the view dependency from the model, the model  code becomes delightful.</p>
<p>Why is the model code so delightful? Let&rsquo;s continue with the address  book application example. The project manager approaches the developer  and says &ldquo;<em>We love the contact list window, but we need a second  window that displays all the contacts by their photos only. The photos  should be in a table layout, with five photos per row</em>.&rdquo;</p>
<p>If the application uses MVC, this task is pretty straight forward.  Currently there are three classes: Person, PersonListController, and  PersonListView. Two classes need to be created: PersonPhotoGridView and&nbsp;  PersonPhotoGridController. The Person class remains the same, and is  easily plugged into the two different views. How delightful.</p>