The role of a model

Maarten's Avatar

Maarten

23 May, 2011 08:25 AM

Hi guys,

My application has multiple "pages", each page has "copy/text" data.
Should I make a model for each page, that contains the copy data for that page?

for example:

loginPage = view
loginPageMediator = mediator
loginPageModel = model

=> the model has following properties :

private var txt_title:copyVO
private var
txt_body:copyVO

I don't think this is a good practice, so I consider just using one "CopyModel", that stores all the copy of the application. All the mediators then use this model for feeding copy to the views. What do you guys think?

Second question regarding models :

Should models store references to displayobjects (other views) ?
I created a mediator for my contextView. The contextview mediator adds other views to the context (background, header).
I also have an application model where I could set references to those added views. I'm thinking about doing this because
it feels like a reference to a child movieclip of a view, can be considered as some kind of data property.

Maarten

  1. 1 Posted by Joe on 23 May, 2011 10:30 PM

    Joe's Avatar

    Maaten,
    I am not really the most qualified to answer your question, however it would seem to me on your 1st question, you could use multiple models if a single model were to get to large, break it down for readability reason. Though, from your explanation it seems you have a VO with only two properties, unless you have a lot of pages or copy/text data I would just create a single model and a set of properties that each reference your VO.
    e.g.
    private var pageOne:copyVO;
    private var pageTwo:copyVO;

    and so on.

    Sorry, but I don't know enough about RL to comment on your second question. Hope I was of some help.

  2. 2 Posted by Maarten on 24 May, 2011 10:20 AM

    Maarten's Avatar

    exactly what I was thinking. For me it looks a bit stupid to create a copy model for each page. I think this would cause too much overhead. One model that stores all copyVO's for the entire application is also easier to manage.

    Maarten

  3. Support Staff 3 Posted by creynders on 24 May, 2011 10:47 AM

    creynders's Avatar

    I'd use one model too.

    Then, for your second question:
    Well, everything in an application is data obviously. Unless you have very good reasons to be storing references to display objects in a model, I wouldn't do it. I could imagine this to be the case in some kind of graphics editing application (and even in that case, I'm not sure it would be necessary), but otherwise ...?
    Models are basically for data storage, manipulation and sharing. It's not as if all data needs to be put into a model.

  4. 4 Posted by Maarten on 30 May, 2011 07:53 AM

    Maarten's Avatar

    Ok, in that case, I'm doing it right. At the moment, I'm not storing any references to views in my models. Each mediator/view is completely independent, so that's the way to it. The thing is that I thought it might be usefull to centralize all references to pages(views) in my application model.

  5. 5 Posted by Tony Smith on 02 Jun, 2011 10:29 PM

    Tony Smith's Avatar

    If you really want a model for each view, this is not unheard of when using a Presentation Model pattern. Joel put together this kick-ass demo application that uses presentation models. Not only that but he only uses signals...no events! It is my new favorite Flex example app.

    http://joelhooks.com/2010/01/16/robotlegs-image-gallery-example-usi...

  6. Support Staff 6 Posted by Ondina D.F. on 02 Nov, 2011 03:27 PM

    Ondina D.F.'s Avatar

    Hi Maarten,
    If you want to continue this discussion, feel free to reopen it. I’m closing the thread now.
    Please open new threads for new issues.
    Thank you.
    Ondina

  7. Ondina D.F. closed this discussion on 02 Nov, 2011 03:27 PM.

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