• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Difference MVC2 vs MVC ???

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi all,

how MVC2 is different from MVC??? what are the advantages in MVC2???.
Thanks in advance!!!

Rahul
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Read this part of "Designing Enterprise Applications with the J2EETM Platform, Second Edition".

In short,
MVC1 (Model 1) = JSP as "V" and "C", JavaBean as "M"
MVC2 (Model 2) = Servlet as "C", JSP as "V", JavaBean as "M"
 
Ranch Hand
Posts: 4982
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Lasse,

As MVC 1 mixes up View and Controller, it seems not a good idea for seperation of responsibility.

However, will there any systems that use MVC-2 is more suitable than MVC-1?

Nick
 
Lasse Koskela
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, that's exactly why MVC2 is the successor for MVC1.
 
Nicholas Cheung
Ranch Hand
Posts: 4982
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oh...sorry, I typed the wrong pharse.

I wanna ask: are there any system that use MVC-1 will be better than MVC-2.

Nick
 
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Nick,

I think small systems will be profit from mvc1 since they do not need the overhead of a full scale mvc2 installation.
Again this could be debatable, however the larger the system the more you need architectural guidelines, or a consistent way of working. This is what mvc2 offers, see it as a best pratice (which is exactly what a design pattern is anyway)

regards,
friso
 
Nicholas Cheung
Ranch Hand
Posts: 4982
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So, are there really any concrete example that systems are making use of MVC-1?

Nick
 
Ranch Hand
Posts: 724
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


I think small systems will be profit from mvc1 since they do not need the overhead of a full scale mvc2 installation



Did anybody measure this overhead?
 
Nicholas Cheung
Ranch Hand
Posts: 4982
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The overhead might not be great becos both Servlet and JSP are located at server side. Also, the overhead might just lie between the transfer of request from JSP to Servlet, becos both of them shall execute the same piece of logic, and both of them in fact will be compiled into Servlet.

Nick
 
Lasse Koskela
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Generally speaking, the "overhead" of MVC2 over MVC1 is that of development effort, not of execution performance. More separation -> more source files -> more to maintain. Obviously the scale tips at some point and the advantage is on MVC2's side. In my experience, that point comes very early in the project size curve.
 
friso dejonge
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks lasse, that is what I meant to say. Yes there are real life applications that do not have mvc2 implementations. I made one with about 20 pages and no beans, just using the session. This works fine, only 20 jsp's Why indeed would I need to create the overhead of actionforms, xml config files, actions etc, (maybe tiles) if it can be done in 20 pages ?
 
Nicholas Cheung
Ranch Hand
Posts: 4982
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


only 20 jsp's Why indeed would I need to create the overhead of actionforms, xml config files, actions etc, (maybe tiles) if it can be done in 20 pages ?


I guess MVC model is not a binding (or equivalent) to Struts, I can have MVC model even in non-Web-based applications (like the SCJD assignment), or just a pure combination of Servlets and JSPs.

In addition, on the development effort, of course it might be easier for developing for single JSP to work out everything, but then it is hard to maintain and reuse if some functions should be common.

This argument seems just backing to the old days that, if I just have small applications, why I need to maintain so many OO classes? I could simply put in everything into 1 or 2 objects to make it works.

Nick
 
David Ulicny
Ranch Hand
Posts: 724
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It is the same as you will not have EJB's in your application, why then use WebSphere if Tomcat will be enough?
 
Nicholas Cheung
Ranch Hand
Posts: 4982
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

It is the same as you will not have EJB's in your application


This might be true.

why then use WebSphere if Tomcat will be enough?


But I wonder any systems in production really use Tomcat. Since there is lack of technical on-call support, thus, I guess only small systems from small firms will use Tomcat in production.

Nick
 
friso dejonge
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

In addition, on the development effort, of course it might be easier for developing for single JSP to work out everything, but then it is hard to maintain and reuse if some functions should be common.

This argument seems just backing to the old days that, if I just have small applications, why I need to maintain so many OO classes? I could simply put in everything into 1 or 2 objects to make it works.



Which is exactly why only small applications (be it webbased or not) will benefit. Which is exactly what Lasse and myself said. Which is exactly the question you asked.
 
Lasse Koskela
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Nicholas Cheung:
But I wonder any systems in production really use Tomcat. Since there is lack of technical on-call support, thus, I guess only small systems from small firms will use Tomcat in production.


Well, practically every single Java hosting provider out there is running Tomcat. That makes a lot of business
 
Nicholas Cheung
Ranch Hand
Posts: 4982
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Which is exactly why only small applications (be it webbased or not) will benefit


That is to say, if your write small applications, even you use Java, you will use 1 single class or as small as possible classes for it?

However, even for small applications, I will try to have *reasonable* # of classes, just if the needed (seperation of the responsibility). And, I will still use MVC model even if I just got 20 pages of JSP. I will just follow a better practice to work with. Otherwise, all things mess up, as you can have a JSP page with 2000+ lines of codes to mess up everything!!!

Thus, we are NOT in the same point of view, and that's NOT what I was asking. And if you are not understand or answering what I was asking, please dont try to put down such statement *Which is exactly the question you asked*.

Nick
 
Nicholas Cheung
Ranch Hand
Posts: 4982
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Well, practically every single Java hosting provider out there is running Tomcat. That makes a lot of business


Well, however, I have just worked with Tomcat in the testing environment, and I havent had any applications that eventally deployed on Tomcat.

Nick
 
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is no such thing as MVC1 or MVC2.

There IS a Model 1 and a Model 2 architecture. Model 1 is client-server. Model 2 IS MVC.

This is a very common mixup because the word Model is also what the M stands for in MVC.
 
Nicholas Cheung
Ranch Hand
Posts: 4982
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

There is no such thing as MVC1 or MVC2


For the terms MVC1 and MVC2, we are actually refering to MVC model 1 and MVC model 2.


There IS a Model 1 and a Model 2 architecture. Model 1 is client-server. Model 2 IS MVC.


I think both models are MVC model, but just in MVC1, JSP acts as both controller and view, while in MVC2, JSP acts as view only, while Servlet acts as controller.


This is a very common mixup because the word Model is also what the M stands for in MVC.


Really having a mix? So far, I havent developed any systems that using JSP as the controller, as if we do so, then, a single JSP might contain thousands line of codes which is very difficult to maintain and reuse the code in future.

Nick
 
Marc Peabody
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Model 1 has nothing to do with the MVC pattern.
You can not say "JSP acts as both controller and view" because that defeats the purpose of the pattern (the purpose of the controller specifically).

You should have come across this question on your SCWCD. If you own the Deshmukh/Malavia book (SCWCD Exam Study Kit) you will find a terrific explanation there on pages 17 and 18.

Other resources for explanations:
http://www.javaworld.com/javaworld/jw-12-1999/jw-12-ssj-jspmvc.html
http://www.fawcette.com/javapro/2002_06/online/servlets_06_11_02/
http://struts.apache.org/
 
friso dejonge
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

That is to say, if your write small applications, even you use Java, you will use 1 single class or as small as possible classes for it?

Well, however, I have just worked with Tomcat in the testing environment, and I havent had any applications that eventally deployed on Tomcat

Really having a mix? So far, I havent developed any systems that using JSP as the controller, as if we do so, then, a single JSP might contain thousands line of codes which is very difficult to maintain and reuse the code in future.


- I agree beforehand that this is a cut/paste from multiple posts, and i hope i havent taken them out of context too much -


Hi, nick,

I think you are mixing things up. Even in Model 1 you can have multiple classes, and therefore multiple jsp's. Using this model you still use multiple
objects, jsp's etc. You are just linking jsp's to each other (with a few helper classes)

On the tomcat thing, that must be the experience.

regards,
friso
 
Lasse Koskela
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Marc Peabody:
Model 1 has nothing to do with the MVC pattern.


Design Patterns are often used not in the exact form they're presented in literature, but in more or less modified forms.

I agree that it would be better to say "Model 1" and "Model 2" instead of "MVC1" and "MVC2". It would be less confusing. However, those terms are being used -- wrongly or not -- also in Sun's own documentation.
 
Marc Peabody
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the link, Lasse.

The chapter says that it references JSP 0.91 and J2EE Blueprints but I could not find MVC1 or MVC2 in either of those documents. I was hoping to find a date somewhere in the Sun ONE Architecture Guide but found none.


This approach ["MVC1"] combines Controller and View functionality within a JSP page and therefore breaks the MVC paradigm.


This point is really more important than the terms used. This is what I mean that Model 1 has nothing to do with MVC. It doesn't fit the essence of the pattern.

It seems that associating Model 1 with MVC is more than just a bit off. It's like saying a duckbilled platypus is a bird except that it flies underwater, drinks its mother's milk, and has fur and therefore breaks the bird paradigm.

If anyone knows of more articles or documentation on this naming issue, please post cause I'd love to read them - more so now for a history lesson on the origins of when and who started saying which.
 
reply
    Bookmark Topic Watch Topic
  • New Topic