Vo's access : directly from view, mediator or only from model ?

aesthetics.data's Avatar

aesthetics.data

09 Feb, 2011 04:00 PM via web

looking at the RL google maps example, I noticed that the GoogleMapMediator uses directly a VO. I thought that a VO should only be used by the model. What is the best practice ?
thanx.

  1. 2 Posted by rob on 09 Feb, 2011 05:11 PM

    rob's Avatar

    As I understood it the VO was what was packaged up by the Service or Model and given to the rest of the application. For instance, if you load some foreign data, rather than handing it off to the rest of the app in its raw form (think a JSON string for instance) you would package it up into a VO and hand that off. This way your actors can be more generic and handle an Object rather than a specifically formated JSON string.

  2. 3 Posted by Glen Whitbeck on 11 Feb, 2011 05:01 AM

    Glen Whitbeck's Avatar

    You definitely don't have to use a Model to benefit from RL. I think the examples use MVC because it is a familiar starting point for most people.

    I personally try really hard to avoid using a singleton model. I find that it leads to a ton of tight-coupling in the application.

    I tend to use a scenario that @rob touched on (Services giving VO's to the application). I usually find that a simple set-up is for a Service to be directly injected into a Mediator. The Mediator calls a method on the Service and the Service dispatches an event containing the resulting VO. The mediator listens for that event and gives the VO to the view.

    So, IMO, yes, the view could directly use a VO (but is totally decoupled from where the VO came from ... the Mediator-Service or Mediator-Event-Command-Service or Mediator-Context Event Listener took care of obtaining the VO).

  3. 4 Posted by creynders on 11 Feb, 2011 03:38 PM

    creynders's Avatar

    VO's are used to transport values around in your application. They can be used by any of the tiers. In general mediators will take the data from a VO and push them to the appropriate properties of the view.

  4. Stray closed this discussion on 16 Feb, 2011 09:12 PM.

Comments are currently closed for this discussion. You can start a new one.