Hi,
I recently read about Model-View-Presenter on Martin Fowler's website, and elsewhere. I think I understand the idea...
The view just displays the GUI components..events fired from the View are delegated to a Presenter. The presenter then deals with the model and updates the View accordingly. Sound about right?
Ok, so I learn best by example..and I haven't found any code samples yet, so I thought I'd give it a shot. Below is my code...
Model View Presenter and here is a simple Main to tie it togehter.
Ok, the idea is this. The GUI shows a checkbox and a textfield. basically, if the checkbox is selected the textfield is enabled and can be typed into. If the checkbox is not selected, the textfield is disabled. From the model point of view, if isClassical is false, then no composer can be defined.
So, is my code following the
pattern? Does anyone have any simple code to contribute as an example? For some reason is just seems weird to me that I would have an interface define a bunch of methods that the Presenter can call. And I have to create the Model and View which get passed to the presenter, and then I have to set the presenter on the view....it just seems weird to me.
Any comments, suggestions, examples??
Thanks for your time and contributions.
Craig