Question: model or view?
Hello there-
I've just started building myself a new website, and I've come to the conclusion that the main, flashy, show-off portion of it would have to be considered a model or a service under Robotlegs, despite the fact that it's on the display list. I just need someone to sense check my rationale for this.
Suppose you have a persistent background that is constantly moving. There are a couple of buttons that people can click on that either trigger responses in the background, or bring up an overlay. These buttons can be considered part of a view. The overlays can be considered other views. User actions trigger commands which are sent through Robotlegs to the background OR to other models / services- for example, posting a link on Twitter, liking it on Facebook, etc.
The advantage is that I'll be able to switch out the background without ditching the rest of the interface. The background can be optimised nicely, and the interface can be changed without recoding the background.
It's a model, but you can see it. So: does this make sense? RL is treating it as a model, but it's on the display list. Another application of this way of thinking would be a game that has a start screen, a pause menu, and a game over screen. The start screen is a view. The pause screen is a view. The game over screen is a view. But the game itself, essentially sitting outside the framework but sending and receiving data to and from it, is best considered a model.
If I've just got the wrong end of the stick I'd love to know that too.
Cheers,
-D
Comments are currently closed for this discussion. You can start a new one.
Keyboard shortcuts
Generic
? | Show this help |
---|---|
ESC | Blurs the current field |
Comment Form
r | Focus the comment reply box |
---|---|
^ + ↩ | Submit the comment |
You can use Command ⌘
instead of Control ^
on Mac
1 Posted by neil on 21 Jan, 2012 03:46 PM
not sure if I completely under stand
I'd say if its in the display list it is a view that is rendering your model.
Support Staff 2 Posted by creynders on 22 Jan, 2012 01:13 PM
it's simple really: if you can see it, it's a view. One that shows a model's state maybe, but it's still a view.
3 Posted by neil on 22 Jan, 2012 03:03 PM
Ok, so the game you illustrate above is not a model. It's a view based module, which will have its own model (which it is rendering) hidden behind it. In robotlegs you would treat it as a view, and use a mediator to convert framework events to the module's api, which, as this is as3 will be exposed through the view.
Does that make sense?
4 Posted by Drumbo on 23 Jan, 2012 01:12 PM
Thanks for the replies. It does make sense; as far as Robotlegs is concerned, this background is view, a black box with an API that can be accessed. Where I'm a little confused is the idea of views talking to other views. Ideally any interface (as in GUI) onto this view will be in it's own view, and clicking a button on the GUI will trigger a response on the background
So, assuming no data is being saved, is the correct chain of events like this:
InterfaceView -> Mediator -> Command -> Mediator -> BackgroundView
or like this:
InterfaceView -> Mediator -> Command -> BackgroundModel -> Command -> Mediator -> BackgroundView
Thanks :)
5 Posted by neil on 23 Jan, 2012 01:32 PM
Remove the commands.
Mediators are inward facing only.
Mediator to mediator comms can be done VIA events only.
Ondina D.F. closed this discussion on 29 Feb, 2012 11:15 AM.