Skip to main content

flaw in MVC pattern? MVC pattern + composite pattern = VMC pattern

No replies
Joined: 2009-06-30

Hi All,

I would like to start a discussion on the classic MVC design pattern used throughout Swing.

I think there might be a flaw in this design pattern because it suggested that a Controller is also interacting with a View. For the more complex Components like JTree and JTable you will see that there is a Selection Model: the selection model receives events from the View and sends out more abstract messages in terms of the rows changed in case of a JTable to Controller(s).

I think there should be a selection model for all components that can be manipulated by the GUI user ( even for Buttons, Check/radio buttons TabbedPane CardLayout etc etc) from which it can receive model change messages. The other way around is also possible that the controller informs the View through the model to i.e. select certain rows in a JTable or to may be even disable the view associated to that Model.

One step further, and this is the whole point of this posting is :

a Controller should only interface with (Data and Selection) models, never with a View directly

in other words :

Models are the conduits between the Controllers and the Views

Having this for all components would make Swing a lot easier.

The GMVC project is actually based on this seperation of Controllers and Views : Controllers should have no idea what kind of View is manipulating the Models from which it receives and sends messages to/from.

So MVC should becomes VMC where the 'M' is the condiut 'through which (POJO) messages will flow which means that a Controller interfaces only with Models and can't 'see' anything of the View. Views on the other hand will not 'see' or know anything of any controller.


'MVC' + 'Composite design pattern' = 'VMC'

I am very interested in comments on this re-definition of the MVC design pattern.