revigniter - Model-View-Controller in Rev terms?

Jeff Massung massung at gmail.com
Sat May 15 17:40:41 EDT 2010


It might be easier to think of a real-world example to use MVC in. Try not
to analogize MVC with something in Rev or another environment that you may
be used to, because what usually ends up happening is that one ends up
sledgehammering a concept into a box that it doesn't quite fit into,
damaging the perception of what that concept actually is.

Try taking something a bit more concrete, that you understand very well, and
create a mental picture of what the Model, View(s) and Controller(s) might
be for it. For example: a checking account.

The model is strictly data. It could be a file on your hard drive, a
database entry on a remote server, or even your balance book.

The controller becomes the method by which the data in the model is changed.
For our checking account, presumably there will be functionality to withdraw
and deposit funds, transfer to another account, etc. The controller is how
the user does this. The controller could be HTTP commands, functions in a
script, or even the teller at your local branch. The controller doesn't even
have to be a user interface. For example (purely for show):

http://chase.com/deposit?acct=2938302&amnt=12.43

The view - on the other hand - is nothing more than the fetching and
representing of the data associated with the model. It could be a bar graph
showing deposits vs. withdraws over a period of time, or just a field
displaying the current balance. It could be an ATM machine, a mobile phone,
a web page, or something else. And just like the controllers, there can be
many views all functioning at once giving you many different views of the
exact same data set.

What's important here is that each of these components are independent of
each other, and they don't even need to all be present [together] to have a
functioning "application." In fact, most MVC architectures are set up in
such a way that this paradigm is magnified. In our example, the model is on
a remote server at a bank. There are many views, and many controllers. Which
view you are using right now has absolutely no bearing on what controller
you happen to be using and vice-versa. You could be standing at an ATM
making a deposit and see the new balance instantly on your Blackberry.

Hope this helps some,

Jeff M.



More information about the use-livecode mailing list