Tuesday, November 24, 2009

Keep your presentation models small

It is tempting to use a presentation model in multiple views. However, this increases the size of the PM. Also it makes it hard to understand.
If you need to share state between two views/pms it might be better to inject a model object into both pms instead.
One example i'm currently working on is the loaded-state of a module. In the module loader i want to update this state and in some other view i want to check it and react accordingly. Instead of having a simple Boolean on a PM and sharing the PM, i'd prefer to create a model object and share it between two independent PMs.

No comments:

Post a Comment