Posted by: ahmedashfaque | May 8, 2015

What is a model-view-controller architecture?

You may have heard about model-view-controller (MVC) architecture but may not have idea about what it is or what it does. Let us understand MVC architecture.

Suppose you are using a software application (e.g. a website). On a web page or this website you need to fill out a form and then submit it. After you submit this form, the database attached to the website will store the information you submitted. Later when you want to see the information stored in the database you can go an edit page and you can see your information and you can even edit it.

What happened in that scenario is that the of the website had collected the information from theĀ user interface (browser) and sent it directly to the database and the data was saved in the database. Simle and straight!

Now imagine you had gone to a website where there was a webpage where you need to make some selection (using radio buttons or selection boxes for instance). From that page you navigate to another webpage and do some more stuff. Now you want to go back to the previous page and see if the selection you made were correct. As a general rule, once you move away from a webpage, any changes made by you on that page should be lost. But you are surprized that the information you selected on that wwebpaage is still there even after you had moved away from that page. The information you selected on this wwebpage was also not saved in the database either. So how this information was still available on that page?

The magic done here is by using MVC. MVC architecture consists of a model, a view and a controller. When a user makes some selection on a webpage then a controller component of the software application stores this information. As long as the user does not submit any information (using a submit button for example), any user selection done on any webpage is saved in the memory through the controller component. Only when a user submits the information using a submit button then the controller directs the model to do computation and also to save information in the database. When the model does this part of computation, it informs the controller. The controller then creates a view and then sends it to the user interface. The user will see the processing for the information he/she submitted.

MVC is used extensively for wewbsites. Using MVC, websites are able to provide persistent user selections even when the users keep browsing a website.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s


%d bloggers like this: