Why is the concept of MVC important?

The concept of the Model View Controler is expressed throughout as an important thing to keep in mind when designing an application. But when developing applications, I try my best to distinguish whether I use the MVC model and whether I harm my application. Why is MVC important for application development and how does it help developers create better software?

+4
source share
4 answers

Well, like so many things in life, it's always good to be well organized. Models, views, and controllers are completely different pieces of code that help provide various functions for your overall project. Because of this, they are kept separate and organized.

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

What problems does this solve? Well, just like the separation of functions solves the problems of readability, modularity and communication, just like MVC. Say, if you want to change a piece of code, you can solve it in a smaller subset, which is more or less isolated from most of the code. This allows you to add, modify or delete code more efficiently and logically. It also helps in testing, since such code is divided into groups, you can better cover your tests. It is also very important that you end up writing much less code.

Hope this helps.

+7
source

Have you heard of the “sharing of concerns”? MVC, in simple terms, is an architecture that allows you to freely connect (or separate) different parts of a system. Views are usually dumb and display data and take user action. Models are data and domain logic in your system. And the controllers maintain communication between the View and the model, often controlling the flow. The source Smalltalk MVC template has many options, and it now seems like every MVC infrastructure.

The benefits of this code make your code less fragile, understandable and understandable, and easier and easier to unit test. All because it is divided into different parts.

A good example is that I recently changed jobs and started working on a new project in PHP (I came from a .NET background). The learning curve was much simpler because we use the MVC framework. Since I already knew the pattern, I knew where everything “was”, as such, and how the system was integrated.

http://en.wikipedia.org/wiki/Model-view-controller https://gamedev.stackexchange.com/questions/5372/mvc-like-compartmentalization-in-games

+4
source

This is a question that you will understand when you experience several software development projects ...

Most notably, it divides the code into logical areas. The user interface code is stored in the user interface (View), business logic is stored in the controller, and objects are stored in the model. If you need to update the user interface, create another interface (for example, a web interface), create web services or not, then you do not need to spend forever and a day cutting through the tangled mash of incomprehensible code. You can also get a different member of the team to specialize in a specific area, such as a user interface or model, and this can lead to more reliable code or, possibly, to allow a younger one to work on something less complicated than the whole picture.

Here is an old article from the previous MVC Framework days when I was working with Microsoft Web Client Software Factory (based on MVC ... or MVPC ... or something else):

http://www.xosoftware.co.uk/post/2010/02/02/Design-Patterns-(As-Used-in-the-Web-Client-Software-Factory-WCSF).aspx

+3
source

You separate the software components and create a design that is loosely coupled. This will simplify maintenance, simplify reading and reduce code, flexibility and expandability. Many things follow this project (sites, mobile applications, etc.).

I can promise you that it is well worth your time. I would suggest going over and starting with something simple, for example (CodeIgniter, PHPBlueprint), just so that your legs are wet and see the MVC work.

A good book to check out is Get Started First Design Templates .

+3
source

Source: https://habr.com/ru/post/1400479/


All Articles