Jimmy Clark wrote:You will only have a single Model layer.....
Jimmy Clark wrote:In the MVC pattern, there is only one Model.
An MVC application may be a collection of model/view/controller triads, each responsible for a different UI element. The Swing GUI system, for example, models almost all interface components as individual MVC systems.
Business applications that do not have a related GUI are not candidates for the MVC pattern.
So it is with many other complex applications that we create that we can create many models for different scale problems and combine them for use in a single application.
Jimmy Clark wrote:One of the more important aspects of understanding the MVC pattern is that the terms "Model", "Controller", and "View" do not translate into a single class for each area. For example, the Struts Controller consists of many, many objects that all interact with each other to "realize" the Controller responsibilities. The View aspect also consists of many parts.
Jimmy Clark wrote:In terms of the Model aspect, this represents the business (domain) logic of the application and typically is many, many, objects all working together to handle their respective parts of the business (domain) functionality.
You will only have a single Model layer. If you have coded functionality in multiple classes, then you should also provide the access point to allow the Controller to effectively communicate with the Model (everything in the Model.) Hope this helps.
pete stein wrote:
Jimmy Clark wrote:Business applications that do not have a related GUI are not candidates for the MVC pattern.
I'm not sure about this either as there are ways to view information that do not involve GUI.
So, as if the Model layer is really the logical interface between the business logic objects, and the controller for each view? (If there is more than one view).
I also have information that will be part of the model, that will not translate directly in a visible screen element, but that nonetheless will allow or impeach manipulation of the main graphical elements.
Jimmy Clark wrote:The role of the Controller is to serve as a delegate between the Model and either one View or multiple View(s). Whether there is one Controller or not depends on the implementation, i.e. if there are multiple Views for example.
Business applications such as batch data processing application which do not invlove human interaction are not candidates for the MVC pattern.
The purpose of the View is to display data and/or input controls for the human user. There typically is a ton of stuff that is happening behind the scenes which the human user never sees, e.g. data manipulation, calculations, processing, connectivity, service invocation, etc.
The elements of the design pattern, Model View Controller are abstract, high-level design aspects. A View represents a set of something that presents a certain style of interface. It is not a single HTML page, it is not a part of a HTML page either. A View is all of your HTML pages or it is the entire desktop application.Ok, important sub-question then, if I have one JFrame in which the same data is represented in two parts of the screen, one that allows manipulation of the data and one that basically serves as a graphical scroll bar, do I then have one or two Views? And if I have two, I suppose I need two Controllers?
Olaf Enulfson wrote:
Jimmy Clark wrote:The role of the Controller is to serve as a delegate between the Model and either one View or multiple View(s). Whether there is one Controller or not depends on the implementation, i.e. if there are multiple Views for example.
Ok, important sub-question then, if I have one JFrame in which the same data is represented in two parts of the screen, one that allows manipulation of the data and one that basically serves as a graphical scroll bar, do I then have one or two Views? And if I have two, I suppose I need two Controllers?
Business applications such as batch data processing application which do not invlove human interaction are not candidates for the MVC pattern.
Yes, of course. That makes sense.
The purpose of the View is to display data and/or input controls for the human user. There typically is a ton of stuff that is happening behind the scenes which the human user never sees, e.g. data manipulation, calculations, processing, connectivity, service invocation, etc.
I don't know if you've looked at my program (ColoredDots). Does that already count as MVC (even though I don't have a controller)? And if not, is it good to model after the MVC calculator example on this page?
And a question for Pete Stein: I see you guys disagree on some points. Are these of major importance concerning my ColoredDots test case program? (Should I be worried?)
Thanks to both of you so far.
Jimmy Clark wrote:A View is all of your HTML pages or it is the entire desktop application.
pete stein wrote:My take on this is yeah, each MVC triad will likely have one model, but your complex GUI application is going to have multiple such triads each interacting with the other.
Jimmy Clark wrote:In terms of your JFrame, the entire screen is your View implementation. You could have a thousand little things on the screen, this is all part of your implementaion of a View.
Your Controller is responsible to accepting data from the Model and making it available for your View. Code in your View will display it in any way you code it.
Jimmy Clark wrote:And when you are coding, you shouldn't be trying to map or connect things too much to design terminology. There oftenn is no logical direct match between the too.
pete stein wrote:YMMV.
Jimmy Clark wrote:Your concept of "MVC" triads is interesting. However, it sounds like you will also have redundant "plumbing" code in the Controller function, i.e. similar logic repeated over and over again.
And then we all jump out and yell "surprise! we got you this tiny ad!"
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
|