Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Model View Controller - does this fit ?

 
HS Thomas
Ranch Hand
Posts: 3404
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have read various descriptions of the Model-View-Controller pattern and can see it's obvious benefits in applying it to designing the GUI.
The most clear-cut is the GoF definition.
The Model is the application object;the View is it's screen presentation , and the Controller defines the way the user interface re-acts to user input

My application has a single model which extends AbstactTableModel and several views that get information from it - the MakeBooking View, the Search View, Add/Update/Delete View. Each separate View has it's own separate controller. A view can notify other views of changes in it's state.
I am confused about references to a single FBNController. Should I have only one FAT Controller ? The advantage of the way I've done it is I can re-use the Views in other apllications especially if I take a JavaBean approach - i.e each view is a JavaBean.
Please comment.
Thanks
 
John Smith
Ranch Hand
Posts: 2937
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

My application has a single model which extends AbstactTableModel and several views that get information from...

It seems a bit strange to me that your application model is represented by a TableModel. For example, it follows from your design that a change in some view (say a text box) may be triggerered from a change in table model. A table is just a visual component which implements its own model-view (MV) pattern in Swing. Your application model, on the other hand, is something a layer above it. So consider this:
-- comboboxes, labels, tables are views
-- a change in application model may need to be reflected in all views
-- table model, combobox model, and other Swing models are just what they are, components of Swing that have nothing to do with your application model.
Eugene.
[ December 09, 2002: Message edited by: Eugene Kononov ]
 
HS Thomas
Ranch Hand
Posts: 3404
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, Eugene.
Yes, the phrase quoted is wrong! I obviously need some practise explaining my design before even attempting the essay exam.
It should be explained somewhere along the lines The application object i.e. Model is the core functionality that is aware of dependent views and controllers
I have heard of the model being described as the data used by the application, but I guess that's also wrong. So, it's not any one thing...
Back to my original question - what's the reasoning behind having just one Controller ?
Is the entire screen presentation seen as just one View, for simplicity / maintenance sake ? Or is this as it should be in practice ?
So if I wanted to re-use the Search View in another application with another Model with different information , is it /isn't it feasible because a View and it's associated Controller should be designed to be linked to one Model :roll: ?
Given the definitions for View and Controller as :
View. Each view corresponds to a particular style and format of presentation of information to the user. The view retrieves data from the model and updates it's presentations when data has been changed in one of the other views. The view creates it's associated controller.
Controller. The controller accepts user input in the form of events that trigger the execution of operations within the model. These may cause changes to the information and in turn trigger updates to all the views ensuring they are all up to date .
 
HS Thomas
Ranch Hand
Posts: 3404
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Note my Search View is a number of ComboBoxes pre-populated with selectable lists of origin airports, destination airports, airlines.
So a change in the model would be reflected in this View.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic