Thursday, 15 March 2018

Understanding MVC - Model–View–Controller

MVC stands for Model–View–Controller



What is MVC ?

MVC is a code organization architecture style to organize your code-logic in a meaningful way.

  • It is an architectural pattern OR
  • It is the name of a methodology or design pattern.
Why it is the use of MVC  or why to use MVC  or What is the goal of MVC ?

well why should I use a filing cabinet or folders to organize my plethora of paper and not just have my papers stashed in a large pile and have others figure how they connect to each other.
  • To separate business logic, data base access and presentation.
  • So that developers can work in parallel on different components without impacting or blocking one another.            
 For example:  Team might divide their developers between the front-end and the back-end
  • To create scalable and extensible projects.
Where MVC is used ?

Traditionally used for desktop graphical user interfaces (GUIs).

  • But the architecture has become popular for designing web applications,mobile, desktop and other clients.
  • Programming languages like Java, C#, Ruby, PHP and others have popular MVC frameworks that are currently being used in web application development.

How it do so?

It divides a given software application into three interconnected parts.
Each of these components are built to handle specific development aspects of an application.

Below are the Three components :

        1. Model                   2. View                     3. Controller

  1. Model  

  • It directly manages the data, logic and rules of the application.
  • 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.
             For example: A Student object will retrieve the Student information from the                                 database, manipulate it and update it data back to the database or use it to render data.

2. View 


  • The view means presentation of data in a particular format, triggered by a controller's decision to present the data.
  • Can be any output representation of information.

3. Controller

  • Act as an interface between Model and View components to process all the business logic and incoming requests, manipulate data using the Model component and interact with the Views to render the final output. 
  • The controller receives the input, it validates the input and then performs the business operation that modifies the state of the data model.

For example: The Student controller will handle all the interactions and inputs from the Student View and update the database using the Student Model. The same controller will be used to view the Student data.

Handaling XLS File In Java

This code will help you to handle xls file in java using apache poi. package test; import java.io.File; import java.io.FileInputStream...