Hi Andrew,
I discovered patterns for the first time when I discovered java in spring of this year. I now recognize the main of them as far as I don't work in the GUI area. Except for MVC (by the way Eugene's example and explanations are amazingly clear, thank you), I cannot name my GUI designs.
Here is an example where you may help me.
In my server GUI, under a main tab "Settings", I have three sub-tabs called "Application", "Database" and "Network". Server-side contents of suncertify.properties is managed from those tabs.
Each of them has a panel on the left side which contains one control per property, and a panel on the right side which contains three buttons : "Save" (saves changes to the file), "Cancel" (cancels changes by reloading from file) and "Reset" (resets all properties to their default values).
After having built the first settings panel, I wanted to reuse the buttons panel for the two next ones. What I did is this :
I defined an interface to be implemented by the left-side settings panels :
and an interface to be implemented by the buttons-panel :
The buttons panel, which is an instance of this class :
receives a link to the settings panel it controls by a call to its method :
Any settings panel extends :
which receives a PropertyFile and a SettingsController in its constructor.
Now each button of SettingsControllerPanel (the buttons panel) may perform its job in an abstract way, simply by calling the save(), cancel() and reset() methods of its SettingsActions. And its setChanged() method can enable/disable the buttons according to the current "changed" state.
Well, as far as design patterns are concerned, my problem is that I cannot name that design. I'd like to because designs are far easier to explain when you can name them (after all it's one of the two contributions of design patterns : help in design and help in design communication).
For me, what I did there is just a trick, not (a) well-known pattern(s).
Can you name it Andrew ? (and BTW tell me if the design seems good to you ?)
Mmh, I am afraid you'll reply something like : "Nice Phil ! It's a very good example of the Trick pattern !"
Best,
Phil.
[ September 23, 2003: Message edited by: Philippe Maquet ]