routers / controllers

Trevor DeVore lists at mangomultimedia.com
Wed Mar 30 08:46:59 EDT 2011


On Tue, Mar 29, 2011 at 9:25 PM, Todd Geist <todd at geistinteractive.com>wrote:

> I am on to exploring the C in MVC, the "Controller".
>
> ...
>
> It occurs to me that LiveCode with its message path might be a nice fit for
> this kind of architecture.  I was thinking putting the Controller in a back
> script, and seeing where that leads me. But it occurs to me that you could
> really put it anywhere as long as the messages you send are pointed at the
> object.
>
> Has anyone messed around with the concept?  Is it useful?  Or is over
> engineering?


I don't think writing your handlers so that they follow the rules of a
controller is over engineering. I find that if I have written my handlers so
that they fulfill the role of model, view or controller then it becomes much
easier to build the application.

I don't know that you necessarily need to store the controller handlers in a
backscript, though. I find it easier to manage an application if the code is
in easy to find places. For single card applications I like to place the
controller handlers in the card script. If the view is made up of multiple
cards then the controller handlers can be moved down to the stack level. If
your controller is managing multiple windows then maybe a central backscript
or library stack is best as the controller handlers are easily accessed
without having to target a specific object every time you want to call one
(e.g. calling "MyControllerHandler" vs. dispatch "MyControllerHandler" to
stack "MyControllerStack").

If your application creates multiple instances of the UI (one window per
open document) then you can still keep the controller code in the card/stack
script by calling upon the power of behaviors. Just assign a behavior to the
card or stack and write your code as you normally would. The behavior can
still use references like "me", "this stack" or "this card" which I find
much more friendly then having to figure which view the controller should
target in a library or backscript.

-- 
Trevor DeVore
Blue Mango Learning Systems
ScreenSteps: http://www.screensteps.com
LiveCode Resources for Developers: http://livecode.bluemangolearning.com



More information about the use-livecode mailing list