Where can I find clear examples of MVC?

I read a couple of things about MVC, but I still don't understand when they should be used and when they should not be used. I am looking for clear examples that say things like “ if you are developing this, then you should use MVC, for example this “ and “ if you are developing this, you should not use MVC. ” Most of the examples I saw are rely on complex structures that have already implemented everything, and you need to study the structure and use it to understand what is actually happening. For many programmers, phrases such as " business user interface logic " sound like marketing terms - for example, the words " Instead, the view is attached directly to the view model " is used in this message.

I know about the dangers that can be hidden in the shadows, since MVC is a concept, and everyone feels that they know it best, but no one knows exactly how to use it, because there can be many variables, and each allowed another The prospect is how to analyze the project in the model, view and controller. There is a lot of theory, but very few clear examples. What I'm looking for is not the “best” ways to do this so that it is not considered subjective; I am looking for various simple implementations that let me decide for myself which ones work best.

In short: What are some good online resources that provide pro and con arguments for using MVC in various situations and provide clear examples to help the reader understand the concept?

+45
model-view-controller
Nov 20 '08 at 10:02
source share
6 answers

IMO, best examples with code and / or starter kits.

Rob Conery has a great number of posts that explain how to create an MVC site using ASP.NET MVC. Each of them has a video tutorial that goes through a discussion on a blog.

The official ASP.NET MVC site also contains several video streams , starter kits ( here , here and here ) and an extra sauce to help.

IMO, MVC is the way for websites. Without spewing all the jargon and marketing, it really breaks your code into nice, separate, and specific sections. Each of these sections can also be tested. It really helps to protect the development process, because you have peace of mind knowing that touching one part of the system does not violate the other (because all tests pass after your last change).

Other blogs you should check out:

+13
Nov 20 '08 at 12:51
source share

Assuming you mean MVC for the Internet, it will be difficult for you to find anything more concise than the following 60 lines of code:

http://code.google.com/p/barebonesmvc-php/

In particular, pay attention to the sendResponse template method, which, in turn, consists of the following two method calls:

applyRequestToModel

applyModelToView

+4
Nov 20 '08 at 12:34
source share

One of the highest ratings I've seen is Learn MVC in 7 days . Of course, whatever one may say, it still pales compared to a book like Pro ASP.NET MVC 4

+2
Feb 15 '13 at 21:57
source share

I did it every time for various projects. From coding everything for the application into one big big PHP script (OK, it started as a small PHP script that just grew up). To use the latest best Spring / Freemarker infrastructure, where my 5O lines of Java code were lost in a sea of ​​XML and template coding.

You can do MVC without a framework, and in php this is probably the easiest way. If all of your navigation code is in one script with just the navigation logic, you do MVC!

For anything other than QDP (Quick Dirty Page), I would recommend using some kind of MVC. Imagine what you will need to do if the business says “can I have a French version” or “an excellent program, but I want to store the data in the xxxxx database”.

+1
Nov 20 '08 at 10:22
source share

There are several flavors of mvc: http://en.wikipedia.org/wiki/Presentation-abstraction-control , http://en.wikipedia.org/wiki/Model_View_Presenter .

also see: http://c2.com/cgi/wiki/like?ModelModelViewController

related question: Examples of a Hierarchical-Model-View-Controller (HMVC)?

+1
Nov 20 '08 at 12:04
source share

Its often difficult to clearly separate the logic of the views from your business logic. If you read abit with the JSF and JSP examples, you can see clear examples of using MVC. Completely shares the view from business logic.

If you are looking for good information about MVC, I can offer http://en.wikipedia.org/wiki/Model-view-controller

This is an important topic, and I really like the idea of ​​separating the different logics. This helps the programmer and everyone else working on the project.

0
Nov 20 '08 at 10:29
source share



All Articles