Passing ValueObjects (VO) to View

thomas.thorstensson's Avatar


17 May, 2011 03:30 PM

Perhaps another simple question:

When a Mediator recieves a payload from a custom event dispatched by Model, I can then either:



view.somesetter = payload

Any preference according to the experts here of the fine Robotlegs ? Are setters okey on Views ? I'm leaning towards the setter approach.

That will be all for today, thanks


  1. Support Staff 1 Posted by Till Schneidere... on 17 May, 2011 04:48 PM

    Till Schneidereit's Avatar

    I don't see any reason why views should be special in any way when it
    comes to this decision. Whatever reasons for using or not using
    setters you might have fully apply to them.

    That being said, my personal rule of thumb is to use setters of
    setting the value is the piece of code's main purpose. If, on the
    other hand, the value is only something needed to perform whatever
    action is invoked, I'd use a method. Of course, this comes down to a
    question of encapsulation: How much of what your view is doing with
    that value should your mediator know.

    As an example, let's say you have sent form data to a server and
    received some kind of answer. Depending on what kind of encapsulation
    you need/ want, you can either simply set the result, using a setter,
    and let the view figure out how (or if) it should be displayed:

    `view.formSubmitResult = result;`

    or interpret the result and instruct the view to display some kind of feedback:


  2. 2 Posted by thomas.thorsten... on 17 May, 2011 07:05 PM

    thomas.thorstensson's Avatar

    Yes makes sense, thanks for the reply. In this case, it's a oneoff so I will simply from mediator pass the value to the relevant method. The Mediator doesn't need to know about it further down the line.

  3. Support Staff 3 Posted by Till Schneidere... on 17 May, 2011 07:25 PM

    Till Schneidereit's Avatar

    Cool, sounds like a good plan.


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

Keyboard shortcuts


? 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