Ross, that has to be the best explanation of MVC I've ever read.  Combined
with your example, I finally *really* understand the concepts.  Thank you!

Bryan Thompson


-----Original Message-----
From: flashcoders-boun...@chattyfig.figleaf.com
[mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Ross
Sclafani
Sent: Wednesday, February 15, 2012 4:05 PM
To: Flash Coders List
Cc: Flash Coders List
Subject: Re: [Flashcoders] MVC style

I am an MVC purist, I always proceed as follows:

Models should ONLY store information, particularly the state of the
application and any data retrieved from disk or the network.

Views hold a reference to a model, watch it for updates, and respond to
those updates by rendering the model in its current state. 'rendering' could
refer to manipulating the display list in flash, outputting some text to
stout (or trace) serving up some JSON from a server app, whatever way of
expressing the state of the model your app requires. Views are also
responsible for  handling events that occur in their domain, and forwarding
them to the appropriate Controllers.
Controllers exist to manipulate models. The only acceptable way to alter a
model is via a controller. Whether its storing data from a Web service in
the model, or altering the state of the app in response to user interaction,
the controllers hold all of the business logic that define how the app
behaves.

Ideally, in AS3, the models consist of no methods except accessors that
retrieve values from private vars and store values there and notify
subscribed views of the update. Event dispatcher is a fantastic base class
for a model.
Equally, wherever possible, a controller should only consist of methods.
Properties are for the model.
This sets up a unidirectional flow of interaction and display. The
controller populates the model, the model notifies the views, the views
change. The changed view incites some user interaction, the view tells the
controller what the user wants to happen, and the controller alters the
state of the model accordingly, which then notifies the views to change, and
so on and so forth.

Ross P. Sclafani
Owner / Creative Director
Neuromantic Industries
http://www.neuromantic.com
http://ross.sclafani.net
http://www.twitter.com/rosssclafani
347.204.5714



_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to