permaculture playing cards*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Fine line between controller and mediator? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Fine line between controller and mediator?" Watch "Fine line between controller and mediator?" New topic
Author

Fine line between controller and mediator?

Venita Glasfurd
Greenhorn

Joined: Sep 11, 2002
Posts: 12
Hi,
I have been reading a lot of posts on the UI Controller and recently came across some on the Mediator pattern too.
I have a Controller for my UI which currently
1. handles all actions on the UI.
2. also takes care of enabling/ disabling buttons and menu items based on the selections(so each component does not need to know the behaviour of the others)

If my understanding is correct, the latter is normally done by a Mediator class.
Would I be right in saying that my Controller is also my Mediator?
Or would I need another mediator class though I fail to see the need for it. Pls shed some light on this as I am quite confused.
Venita.
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
Hi Venita,
That sounds like a Mediator to me. In the normal implementation of the Mediator Pattern, there is one class responsible for keeping all the Colleagues in synch. For this assignment I used a variation in which the Colleagues were responsible for keeping their own state in synch base on dispatched properties thru the Mediator.
Hope this helps,
Michael Morris


Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
Venita Glasfurd
Greenhorn

Joined: Sep 11, 2002
Posts: 12
Hi Michael,
I took a look at a post where you've discussed the Component Mediator using a PropertyChangeListener and it is very impressive, but since this is a lot new to me, would like to give it some more thought before I go into it.
My question is: is it possible for a Controller to be a mediator at the same time? Or is Controller a misnomer in this case?
Venita.
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
Hi Venita,

My question is: is it possible for a Controller to be a mediator at the same time? Or is Controller a misnomer in this case?

I would say yes, it's just a matter of semantics. One would think of a Controller controlling a single object and a Mediator as controlling multiple objects, but that characterization is not always true.
Michael Morris
 
Consider Paul's rocket mass heater.
 
subject: Fine line between controller and mediator?
 
Similar Threads
Help with Mediator Pattern
what pattern(s) would you vote off the island?
MVC pattern for GUI
Inner classes and Mediator Pattern
URLyBird Client GUI