Say Hello To MVC

I think you may familiar with this term.I know you may have dealt with these things.Being an IT guy i am trying to simplify this concept “Mystery of MVC Architecture” in this post.First of all its not a big deal weither you are having IT background or not.Its important to know some of ongoing(indstry standard concepts) around you.Lets start

MVC stands for Model-View-Controller defines your application’s(web based) architecture.Before getting to involve programming and coding stuff,a set of Higher industry level guys(Software/Application Architect) decide the flow of coming product and set a standard format to write thousand lines of code.This format is nothing but your MVC.So in simple term to manage and way to write code for any web application,MVC is used.

“Model–view–controller (MVC) is a software architecture pattern that separates the representation of information from the user’s interaction with it.” According to Wikipedia. Now one question is in your mind that how this technique helps in code???Yes indeed,this helps developer like us a lot.Being as a developer, we have to write many thousand lines of code for development.This is not just end,it would become more panic situation when some projects come for maintenance and you have to go through all these lines of code and figure it out where bug(fault) is.This is really a hectic tasks for any developer.So that to reduce that effort and manage codes in a proper strcture,MVC has been adopted in most of the modern languages like ASP.NET,Java(Spring/Struts),Php(cakephp,Codignator),Python(django) etc.

Lets tour of its technicality, how can you achieve MVC structure in your product(application) development.Concept is peddy simple along with its implementation. If you are using any MVC based Framework,then half of your work is done.Because you don’t really have to worry about seperatization of your code.But in normal scenario,say you are using core php(no framework), then you have to separate your code and divide them into three parts:-

  1. Model :
  2. This section/part deals with database.So in order to store data,controller passes request to it to store/fetching records from database.This is the prime area of generating your output of your sent request.

  3. View :
  4. This is used to to display/render output(presents result) from model.This is section where user(end-users/site viewer) interact with.So here basically used to send inputs may be via form and display result in hypertext format.

  5. Controller :
  6. This controls the flows of your request.It send request to model to fetching/storing information/records into database and display/take inputs into/from views.

    So there could be two simple flow in this architecture:-
    1. Submit From(view) —-send request—->Controller—->Process and deliever—->Model—–>Store(into Database)
    2. Database(model)—->Controller—–Success/Failure Msg—->Web page(View).

    mvc-model

    Recommendation: If you are going to write some code and want to follow MVC structure, then directory seperatization is not enough,but also every file should be written for specific purpose and needs to be a part of one of these three.By using MVC, use can not only save your time but there are lots of advantages including Save Testing Time,Re-use of your code,Ease of maintain,easy debug etc.

    You can refer How to adopt MVC in your coding