Anda di halaman 1dari 2

MVC Architecture MVC Architecture has implemented by Trygve Reenskaug at 1979 for the first time.

It was implemented on Smalltalk at Xerox labs. Then benefits and advantages of this architecture has been accepted by most of the coders and software engineers. It was an information about MVCs history above. Now lets talk about what really MVC is. What do you understand from MVC. The word M stands for Model, V stands for View and C stands for Controller. I am going to mention about each item.

The figure above may help you while thinking what structure it might have. Lets start with Model. Model: It handles data processing and database works part. Model processes events sent by controller. After processing these events then it sends processed data to controller (thus, controller may reprocess it) or directly to view side. View: View prepares an interface to show to the user. Controller or model tells view what to show to the user. Also view handles requests from user and informs controller. Controller: Lets say controller is like brain of the system. That is right. Because it processes every request, prepares other parts of the system like model and view. Then the system determines what to do by contro llers commands. Even if you are junior developer you probably faced with a problem called Complexity of Project. There MVC comes. MVC helps you to decrease complexity of project. For instance, there is a team with 5 people. If they are working on same project after sometime project reaches a point which no one cannot understand what is project going to be. What i mean is MVC splits project to (by default) three different parts. Like Model, View, Controller.You can say;

As you see above if you split your project three part like Application Development, Database and Data processing and Interface development then of course you project will be more understandable and developers can work more efficiently. What are the advantages of MVC? MVC is perfect for team work. As i mention before this architecture splits your project into some parts so, team members can work and their parts without any dependency. Then you will realize that MVC makes your project more systematic. It is really easy to edit or change some part of your project that makes less development cost and maintenance cost. MVC doesnt repeats itself. If you wrote some script for your project. Because of non -dependancy property of MVC then you may use this script for another project of yours. And of course it helps you to finish your project by spending

less time then others. And developers doesnt fight after 5pm Why MVC is non-standard? Still waits for developers to discover itself. I know some developers who think that they have to write even every semicolon, letter. you dont have to do that. However, MVC tries to help you to dont repeat yourself. Why MVC is too important for Companies? Well it is not!. Yes that is true. A company only looks for if a project is done on time or not. Most of the companies doesnt interested what structure you are using while developing. Probably you know this formula : P=W/T (P:Power W:Work T:Time) As you see here if you descrease the time so you may done with more Work. That means money! So, you see how MVC helps you. Example: As an example you can think like eyes of a human stands for view, brain stands for controller and neutral system of a body stands for model. You can imagine like when a person sees his friend eyes (view) tells this to the brain (controller). Brain wants to show smile to his friend. To make it possible brain tells your faces neutral network that make the face smile. Then his face smiles Hope it helped. MVC: Model View Controller or MVC as it is popularly called, is a software design pattern for developing web applications. A Model View Controller pattern is made up of the following three parts: Model - The lowest level of the pattern which is responsible for maintaining data. View - This is responsible for displaying all or a portion of the data to the user. Controller - Software Code that controls the interactions between the Model and View. MVC is popular as it isolates the application logic from the user interface layer and supports separation of concerns. Here the Controller receives all requests for the application and then works with the Model to prepare any data needed by the View. The View then uses the data prepared by the Controller to generate a final presentable response. The MVC abstraction can be graphically represented as follows. The model: The model is responsible for managing the data of the application. It responds to the request from the view and it also responds to instructions from the controller to update itself. The view: A presentation of data in a particular format, triggered by a controller's decision to present the data. They are script based templating systems like JSP, ASP, PHP and very easy to integrate with AJAX technology. The controller: The controller is responsible for responding to user input and perform interactions on the data model objects. The controller receives the input, it validates the input and then performs the business operation that modifies the state of the data model. Struts2 is a MVC based framework. In the coming chapters, let us see how we can use the MVC methodology within Struts2.