What is MVC Architecture? Why Use it?

So you have been coding applications for a while and now you are facing an issue with debugging…

You are taking too much time to develop and deploy your application to production server..

You are ready to take things to the next level, which means, you want to develop and deploy applications faster, debug the applications quicker and without tampering the UI of the application.

Yes, i know it. I feel your pain.

Back in the day in the college, i was asked to develop an attendance management system for my college.

It took my 6-8 months to develop it because i used to plain old sequential programming approach with functions scattered everywhere.

No matter how much I tried i wasnt able to organize things. Although everything worked fine.

This is where i looked at frameworks which enabled to do rapid application development, in short, RAD.

…and all frameworks had something in common…

It looked somehow organized and as i glanced through the documentation i came across the term, MVC.

So What is MVC?

As per the official definition, Model-view-controller (MVC) is a software architectural pattern for implementing user interfaces.

It divides a given software application into three interconnected parts, namely Model, View, Controller.

Each of these components are built to handle specific development aspects of an application.

MVC is one of the most frequently used industry-standard web development framework to create scalable and extensible projects.

It makes your development so much easier even if you have the most complex of COMPLEX of requirements you will be able to handle the the look and feel as well as the logic of the application easily and efficiently.

Yes, no more days where you will pull out your hair and think, “WTF, did i write?”.

I have had these moments when i was developing my final year engineering project, Deeptrawl, an intranet based search engine.

so lets go deeper…

Components of MVC

Model: The Model component represents all the data related logic that the user works with, like the data that is being transferred between the View and Controller components. Basically, all the database related queries comes here, so you are not messing those queries along with the design of the application like the way you may have used to do before.

View: The View component is used for all the User Interface of the application. I would say these as the templates for the application, which means the HTML/CSS/jQuery and all front-end engineering codes come here. So if there is a slight change in the design you dont have mess around with the logic of the data.

Controller: Controllers as the name sounds “controls” what model to use and what view to display to the user, it collects all the incoming data initially before communicating with the database, meaning, this where we do form validations, user login verification (after getting some info from the database, ofcourse).

To put things into perspective and perhaps more clear…

mvc

Depending on the platfor you choose to develop on, the MVC architecture could differ from each other, but it will always serve the same purpose as i have mentioned in this blog post.

In upcoming blog posts, i would discuss about each of these implementation for a few platforms i like to develop on, so stick around for more good stuff.

Thank you for stopping by and reading this article. Let me know your thoughts in the comments, below.

Later. Cheers.