What is MVC and what are its benefits?

I found What is mvp and mvc, and what is the difference , but in fact he did not answer this question.

I recently started using MVC because it is part of the structure that my partner and I will use. We chose it because it looked like an easy and separate process from the display, are there any advantages besides this that we don’t know about and could miss?

Pros

  • Display and processing are separate.


against

  • not yet
+43
design-patterns model-view-controller
Aug 25 '08 at 19:26
source share
11 answers

MVC is the separation of m odel, v iew and c ontroller - nothing more, nothing more. This is just a paradigm; The ideal you must have in your mind when developing classes. Avoid mixing code from three categories into one class.

For example, while the presentation of the grid table should obviously represent the data after the show, it should not contain code on which to extract the data or what is their own structure (model). Similarly, although it may have a function to summarize a column, the actual summation must be done in the controller.

The Save File (View) dialog box ultimately transfers the path that the user selected to the controller, which then queries the data model and performs the actual savings.

This separation of duties allows you to flexibly move along the road. For example, since the view does not care about the base model, supporting multiple file formats is simpler: just add a subclass of the model for each.

+44
Aug 25 '08 at 19:31
source share
— -

Sharing concerns is a big question.

The ability to tease these components separately makes the code easier to reuse and independently test. If you really don’t know what MVC is, be careful when trying to understand the opinions of people, as there is still some opinion about what a “Model” is (whether it is business objects / DataSets / DataTables or if it represents a basic service layer).

I saw all sorts of implementations that call themselves MVC, but not quite so, and the comments in Jeff's article show that MVC is a moot point, which I don’t think developers will ever fully agree.

Good rounding of all the various types of MVC is available here .

+12
Aug 25 '08 at 20:57
source share

Jeff has a post about this, otherwise I found some useful docs on the Apple website in Cocoa tutorials ( this one .

+6
Aug 25 '08 at 19:31
source share

I think another advantage of using the MVC pattern is that it opens the door to other design approaches, such as MVP / Presenter, and many other MV * patterns.

Without this fundamental segregation of the “components” of design, adopting these methods would be much more difficult.

I think this helps make your code even more interface-based. Not only as part of a separate project, but you can almost start developing common “views”, which means that you can use the template for more “grunt” code in your applications. For example, a very abstract “data view” that simply takes a bunch of data and displays it on a common grid layout.

Edit:

If I remember correctly, this is a pretty good podcast on MV * templates (listened to this a while ago!)

+3
Aug 25 '08 at 20:57
source share

One of the things that I can think of is very quick access to your data in your view (for example, game animation data, such as bone positions). In this case, it is very difficult to maintain the separation layer.

Otherwise, for most other applications that are more data-driven than with graphics, it seems like a logical way to control the user interface.

+1
Aug 25 '08 at 21:01
source share

If you follow the stackoverflow podcasts, you can hear how Jeff (and Jeff?) Discuss his greatness. http://blog.stackoverflow.com/2008/08/podcast-17/ . But remember that using these separate layers means that things will be easier in the future - and now more complicated. And layers can make things slower. And you may not need them. But do not let this stop you from knowing what it is - when creating large, reliable, long-lived systems, it is priceless.

+1
Aug 26 '08 at 3:03
source share

Separates the model and view controlled by the controller. As for the model, your models should follow the OO architecture, future improvements and other maintenance of the code base should be very easy, and the code base should be reused.

The same model can have any no.of representation, for example), the same information can be shown in the form of different graphical representations. There can be different no.of models in the same view. For example, various details can be displayed as a single graph, called a histogram. This is what is reusing both View and Model.

Improvements in presentations and other support for new technologies for creating presentations can be easily implemented.

The guy who works on the viewing dose should not know about the base code base of the code and its architecture, on the contrary, for the model.

+1
Apr 05 '10 at 19:02
source share

One of the main benefits of MVC that was not mentioned here is that MVC provides RESTful URLs that allow SEO. When you name your controllers and actions wisely, it will make it easier for search engines to find your site if they only look at your Urls site. For example, you have a website for selling cars and a page that displays available Lamborghini Veneno cars, instead of having www.MyCarSale.com/product/6548 with a link to a page that you can select www.MyCarSale.com/SportCar / Lamborghini-Veneno url for Target SEO.

Here is a good answer to MVC Advantages and here is an article on How to Build a Friendly URL for SEO.

+1
Jan 27 '16 at 0:40
source share

The main advantage of the MVC architecture is the differentiation of project levels in the model, presentation and controller for code reuse, easy to maintain code and maintenance. The best thing is that the developer feels good to add code between serving the project.

Here you can see a few more points. Main advantages of MVC architecture .

0
Jul 02 '14 at 2:30
source share

! [mvc architecture] [1]

Model-view-controller (MVC) is an architectural model of software for implementing user interfaces. He divides this software application into three interconnected parts in order to separate the internal representations of information from the ways of presenting or accepting information from the user.

0
Jul 16 '14 at 10:35
source share

MVC is just a general design pattern, which in the context of developing poor web applications allows the developer to save HTML markup at the application presentation level (presentation) separately from the methods that receive and process client requests (controllers) and data representations that are returned in the view (models). All this concerns the separation of problems, that is, the preservation of code that serves one functional purpose (for example, processing client requests) sequestered from code that performs a completely different functional purpose (for example, data presentation).

The same principle, why someone who spent more than 5 minutes creating a website can appreciate the need to keep your HTML, JavaScript, and CSS markup in separate files: if you just dump all your code into one file, you end up with spaghetti, which will subsequently be unavailable for editing.

Since you asked about possible "minuses": I do not trust the design of software architecture, but based on my experience in MVC development, I think it is also important to note that after strict -frills the MVC design template is most useful for 1 ) lightweight web applications; or 2) as the user interface layer of a larger enterprise application. I am surprised that this specification did not talk about more, because MVC does not contain explicit definitions for your business logic, domain models or really nothing at the data access level of your application. When I started developing in ASP.NET MVC (i.e., before I knew that other software architectures existed, even existed), I get very bloated controllers or even presentation models full of business logic, which if if I were working on enterprise applications, it makes it difficult for other developers who are not familiar with my code to change (i.e. more spaghetti).

0
Sep 18 '15 at 3:18
source share



All Articles