Jason Cavett skrev:
> > JasonCavettwrote:
> > > I have a question about the use of listeners in MVC.
Schnip.
> Okay, thanks for the explanation.
Hmm.
MVC is one of those super-powerful patterns that illuminates the
paradox of patterns themselves, namely:
- Patterns are a useful communications short-cut, distilling historical
solutions to well-known problems.
- Patterns can obscure the very problems they attempt to solve, leaving
designers concentrating more on implementing the pattern than checking
that the actual solution they are trying to solve is the same that
which the pattern was invented for. "Wood-for-the-trees."
So - for the briefest of moments - ignore the pattern and acknowledge
that what you are trying to do is encapsulate your GUI from the rest of
your software. Try to find the best way to do that, and if you end up
with MVC, then fine. If you don't, then MVC is the wrong pattern for
you.
This is probably why there are so many variations of MVC out there: one
size does not fit all.
To take a practical example, here's a poker game with an MVC variation.
The View could be web-based or Swing-based; but there will certainly be
a View. Based on this, the Model accesses the View interface directly.
It doesn't fire off events in the hope that some View is watching,
because it knows that there will always be one View (though it doesn't
care what particularl implementation the View has). Hence:
Observer-pattern unnecessary:
http://www.edmundkirwan.com/servlet/fractal/cs1/frac-cs100.html
.ed
--
www.EdmundKirwan.com - Home of The Fractal Class Composition