Mediator Pattern

Mediator Pattern

Old forum URL: forums.lhotka.net/forums/t/1517.aspx


deveb posted on Tuesday, October 17, 2006

Hi,
I have a question on the use of mediator pattern with GUI, and not sure if it is related to this forum.
I come across the Mediator pattern and some code examples on its use in GUI framework design.
I wonder if in complex UI design, does Mediator pattern applicable especially if there is a lot of controls and object. The mediator class would be exploded with all these classes.
By the way, does CSLA make use of mediator pattern in the design?


RockfordLhotka replied on Tuesday, October 17, 2006

CSLA supports the interfaces and events defined by data binding, deferring mediation between the model and view to data binding itself.

You can, if you choose, view data binding as the "Presenter" in MVP, or as a Mediator, or maybe even as an Observer.

I love patterns. Patterns rock. But it is very important to realize that most of the core patterns are already implemented by the platform. Sure, there are cases where you might implement some of these patterns in your own code, but I think it is more important to recognize where they are used (in whole or part) within .NET itself - so you can better exploit those pre-existing implementations.

Last week, at the Patterns and Practices Summit (which is a great conference btw), one speaker walked through implementing an MVP pattern to put some data into a treeview. It was an interesting excercise in an academic sense, but people would be foolish (imo) to do that in real life - because data binding would have accomplished the same thing with about 5% of the coding he had to do.

Of course one TDD expert pointed out that with data binding you couldn't have tested all the code. Which is true - but I'm not sure writing and testing dozens of lines of code is better than writing 2-3 lines of code and trusting that .NET actually works... If you decide you don't trust data binding, then do you trust the rest of .NET? The compilers? Windows itself? It is a slipperly slope, no doubt there!

Copyright (c) Marimer LLC