Simple Explanation of Model View Controller (MVC)
Posted on 9th August 2017
- Takes 2
minutes to read
Model view controller is a type of software architecture that is designed to separate the programming code that handles presentation, application logic and business logic.
This makes systems using a model view controller architecture much simpler to maintain, as locating the code relevant to specific logic is significantly easier. Additionally, it makes expansion of systems much less complex, as it avoids the ‘feature cascade’ effect in which the addition of a single feature will result in a knock on or butterfly effect throughout the entire system.
The parts of a model view controller system are referred to as models, views and controllers, which makes perfect sense. The definition of these system parts is also quite intuitive.
- Views – Views are entirely for the presentation part of your application. It contains no brains, no logic, no intelligence to the extent permissible by the programming language used. A view is merely the appearance of your application and nothing else.
- Controllers – A controller handles feedback from the user and logic specific to the application. A controllers job is to receive input from a user, via controls found on the user interface of a view, to process it, communicating with a model if necessary, and then to send output to the user, usually by populating a view with relevant content.
- Models – Models perform business logic. Business logic, in this case, refers to items that are fundamental to the overall system design. For example, if a library application was constructed, the logic which ensured a library card owner only rented up to 5 books at a time, would be part of a model. Again, as part of the business logic, models also tend to control access to application storage, such as database(s), performing CRUD (creation, updating and deletion) tasks on the stored data.
I hope this helps explain the basics of the model view controller software architecture.
Model View Controller