Class 1, Part 2 |
Intro to Java 30-IT-396 |
|
Another Example: Streamers
-
But why go through so much effort? Why don't I just tell the view
exactly what I want?
-
Well, with model-view-controller (MVC), the look of the interface is separated
from the data. So, that means you can plug in a new view very easily,
without chaning the representation of the data. You can even have
two simultaneous views.
-
Another example... Many on-line brokerages offer a streamer., which constantly
sends live stock quotes to the brokerage's customers. Let's say we
have three customers with different interfaces-Macintosh, Windows, and
Unix. Each user has an interface that matches his or her desktop.
This is fine, the views can be different, because the view is separated
from the data.
-
When a stock quote changes, the brokerage passes this information to its
customers. Perhaps it sends a Java object, via Remote Method Invocation,
that has the stock ticker symbol and its price. This is the model.
-
The controller has a method for accepting that object, and can update
the view.
-
Again, the view is what the user sees. When the controller
updates that view with the new data, the user sees the new data.
Since the data and view are separate, each user sees the data in the preferred
format.
-
-
What if the brokerage even offers different ways to see the data?
-
In the above example, we assume that the users are using a 'fat client',
or an application with an icon that starts it up, and a Swing-based interface.
-
Say the brokerage wants to have streaming information on its website as
well. It can do this either with HTML or a Java Applet. The
HTML and the Applet are the view in this case. Theoretically, the
brokerage can re-use the same model, and perhaps even the same controller,
with only having a different view! Imagine the savings in writing
and maintaining only one small set of objects for each of these presentations!
Layout Management



Created by: Brandan
Jones January 4, 2002