Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is the MVC concept important? [closed]

The Model View Controller concept is expressed all over the place as an important thing to keep in mind when developing an application. But when developing applications, I struggle to distinguish whether or not I'm using the MVC model and whether or not that is hurting my application. Why is the MVC concept important in application development and how does it help developers make better programs?

like image 820
Seany242 Avatar asked Mar 08 '12 22:03

Seany242


People also ask

Why the MVC is important?

MVC is important to understand because it is the basic structure which most web applications are built on. The same is also true for mobile apps and desktop programs. There are many variations around the basic idea of MVC.

What is the main advantage of MVC pattern?

Faster development process: MVC supports rapid and parallel development. If an MVC model is used to develop any particular web application then it is possible that one programmer can work on the view while the other can work on the controller to create the business logic of the web application.

What problem does MVC solve?

The MVC pattern solves this problem by dividing a program into three parts: The Model, which contains the computational part of the program, i.e., which provides access to the system's core functionality, the system's state information, and a state change notification system.

What is are the disadvantages of the MVC model?

The main disadvantage of MVC Architecture is it cant be suitable for small applications which has adverse effect in the application's performance and design.


1 Answers

Well, like doing many things in life, it always helpful to be well organized. Models, Views and Controllers are distinctly different pieces of code that helps to provide different functions to your overall project. Because of that, they are kept separate and organized.

Imagine if you were designing a program. You wouldn't put all your code into one function, would you? No, you would divide them up into separate smaller functions that solve very specific tasks. Likewise, as programmers, we're constantly looking for ways to separate and divide our large applications to smaller bits of pieces. One of these organization design patterns is MVC, where, the model (the data) exists in one section, the view (the UI) exist in one section, and the controller (logic) exists in another section.

What problems does this solve? Well, just as how having separated functions solve the problems of readability, modularity, and coupling, so does MVC. Say if you wanted to change a piece of code, you can tackle it in a smaller subset that is more or less isolated from the larger piece of code. This allows you to add, modify or remove code more effeciently and logically. It also helps in testing, since similar code is sectioned into groups, you may be able to have better coverage of your tests cases. Also very important is that you end up writing a lot less code.

Hope this helps.

like image 175
Vu Tran Avatar answered Sep 30 '22 07:09

Vu Tran