Modern software development is a combination of structured code, databases spanning a large number of interrelated tables and deadlines due yesterday. Today I'm going to discuss the Model-View-Controller architecture of organizing code.
History of MVC
Before I continue, I want to be clear, you can just as easily write your entire application in a single long page spanning thousands or more lines of code. This is perfectly acceptable if you don't mind the extended effort of maintaining the code in the future. However, modern software requires organized structure. Even the best commented code is hard to return to once you are not actively working on the original codebase. Instead of flooding a single page with code, your efforts tend to be better served when it's organized into multiple files, each file handling a specific segment of the application. Maintainability sky-rockets when you have structured code, especially if you are developing this with a team.
Model-view-controller separates the code into three distinct parts:
Model — the files that handles application logic, such as what data is saved, and how that data should react to certain commands, etc.
View — the output displayed to the user is part of the view. It takes the data from the Model and the Controller to display the information.
Controller — this section handles the user / system input, then informs the other two parts to make appropriate changes.
Example: Spreadsheet using MVC
Using a spreadsheet application as an example:
The example above is very simple. In a complete application, there are multiple models, views, and controllers. Each having a specific role, and when utilized as a whole, output the view.
For short: Model-View-Controller is simply Logic-Output-Input