views:

1105

answers:

7

Note that I am not asking which to choose (MVC or MVP), but rather if one of the two should be used for a web application.

I realize that it might be too much work to convert an older application from its current design to a MVC or MVP pattern. However, what about for a new app? It appears these are the most popular architecture patterns, so should one of these be chosen? If not, what other patterns are there?

If you are not familiar with MVC and/or MVP, a good question to check out is "What are MVP and MVC and what is the difference?". It has many good answers, including links to various websites that break down each one.

+2  A: 

Both are great options.

I'd go for MVC as it has a wider adoptions and its easier to understand and use to frontend (HTML / CSS) developers.

Also, given the number of frameworks adopting the MVC pattern, chanches are talking with your coworkers in MVC you will talk a well knew language.

Luca
"Note that I am not asking which to choose (MVC or MVP), but rather if one of the two should be used for a web application."
bzlm
A: 

It depends on the framework you're using. Just use what it supports. Most web frameworks I've seen use the front controller pattern and call it MVC or MVP.

Mendelt
+3  A: 

MVP / MVC works well in web applications because the HTTP verb + URL combination is a very good way to determine which action to take. There are reasons not to use it, such as if your team has a lot of experience with another framework, but I would generally recommend an MVP / MVC framework. Your application will be finished quicker with higher quality.

Dan Goldstein
What about without a framework and just following the MVC or MVP pattern? I'm guessing it would be slower, but still of the higher quality. Would you agree with this assessment?
Thomas Owens
You would most likely be "Recreating a Square Wheel" meaning you would be creating something that already exists only poorer. There are simple MVC solutions out there and creating your own pattern when great ones exist might be foolish and a time waster. This doesn't mean you can't.
Syntax
I agree. Don't brew your own - there are plenty of great MVC/MVP frameworks for every situation.
bzlm
Are you serious? You're advising to re-architect an entire web site to make the URLs simpler?! If the URLs are a big deal you can get an app do change the URLs with almost no effort. There are a lot of zealots out there recomending design patterns they don't really understand--suggest caution.
alchemical
I'm not suggesting that you rewrite anything. The question is about new sites. I meant that using the URL to decide what action to take is intuitive for both the developer and the customer. I like it better than using the querystring like "Student.aspx?mode=edit".
Dan Goldstein
A: 

I think that you should. They are harder to implement, especially in MS world because they did everything to push Web Forms and make building web applications more easily.
Using them you are programming straightforward and you feel like you've done a lot of work. But they are slower and harder to maintain after your site gets bigger.
Using MVC and MVP allows you to separate model(basic classes that represent domain you are working with), controller and views. The best thing about that is that you can reuse your model in other applications like mobile applications or windows apps. They then have more in common than just a database so you have to write less code. You just have to write controllers and views.
I am new to this but I see benefits because when I had to change something on one place something else crashed elsewhere(so you also have to get loose coupling into account and writing unit tests). Writing tests is impossible in Web Forms.

However, if you are building application to represent a person or a company, where there is no business logic on the web, and you have to do it fast, Web Forms are good for it. And also for building prototypes so you can show what application will be able to do when finished.

gljivar
MVC is harder to implement in MS world? Dude, have you ever heard of ASP.NET MVC?
bzlm
Dude I have heard. And have you heard that it is not yet released. I was talking about the times since introducing ASP.NET till now.
gljivar
A: 

I would prefer the MVC Pattern, just because the loose coupling. There is a clear seperation between model, view and controller and through the isolation it`s better suited for Test-Driven Development or just Unit-Testing.

cordellcp3
if you implement MVP in the correct way then is also suited for TDD
JSC
"Note that I am not asking which to choose (MVC or MVP), but rather if one of the two should be used for a web application."
bzlm
A: 

Your question was "should I use one of these design patterns".

I'd have to say that that really depends on the scope of your project. On a very large project that has interdependencies with other systems in a large organization with a large budget, I'd say they are definitely worth considering.

I think these patterns are often over-used on smaller projects where they may add unneeded complexity and cost.

The main point of loose-coupling, is so that you can change your DB or UI at a later time, or re-use business logic. Often times, this never happens. You have to realize that either of these patterns will take longer to implement and complicate the code quite a bit. So, I strongly suggest really thinking this over and weighing your options. You can often deliver a better solution faster by using a very simple architecture that gets the job done and reduces complexity!

alchemical
Come on folks -- if you're going to vote it down, at least have the courtesy to leave a comment! I'd like to know what your thoughts are, seriously.
alchemical
The main point of loose coupling is to improve the design and testability of your code, not so that you can replace your db or UI at a later time. MV* encompasses separation of concerns which localizes the logic for each of the primary concerns into the classes implementing those concerns rather than scattering it across all the classes in the application. This should aid in understanding the code in projects of all sizes. Any project can benefit from MV*, though the larger the project the more benefit you get from it.
tvanfosson
A: 

I like both patterns. My best practice is to choose an pattern, that is always better then NO pattern.

I've developed many applications on both patterns, my personal feeling is that when you are an RAD developer and you are not so good with CSS & javascript(Mostly winforms developers who want's to create an webapp, no offense ;-) ) You should use the MVP pattern because this is very easy to use with the Web Application Projects.

But when you known allot of CSS & javascript then you should consider the ASP.NET MVC pattern.

JSC
"Note that I am not asking which to choose (MVC or MVP), but rather if one of the two should be used for a web application."
bzlm
I know that you don't ask to choose an pattern but I only want to provide some points to consider if someone is choosing an pattern.
JSC