On Vew Mediators

's Avatar

dbouzolin

08 Apr, 2010 03:47 PM

I wonder why not to make the framework more declarative. For instance, instead of:
// In Mediator: [Inject] public var simpleView:SimpleView;

// In Context: mediatorMap.mapView(SimpleView, SimpleViewMediator);

// Just have this: [Inject(mediator='SimpleViewMediator')] public var simpleView:SimpleView;

And have the Context to map the view into mediator this way?

Same with the models. Instead:

injector.mapSingleton(SimpleModel);

Have it declared in the model itself:

    [Inject(context='MyContextClass')]
public class SimpleModel extends Actor {
    private var message: String;
    ...

Thanks,
Dmitry.

  1. Support Staff 1 Posted by Shaun Smith on 08 Apr, 2010 08:12 PM

    Shaun Smith's Avatar

    Hi Dmitry,

    That's a good idea, but I see a couple of problems with that approach:

    1. We'd still need to do the mappings somewhere in order to process the Mediator/Model (to inspect its metadata), so at very best it would just shorten the mappings: mediatorMap.mapView(SomeMediator);

    2. It's far less flexible: the point of Inversion of Control is to remove those kinds of configuration decisions from inside our business classes and place them in a more sensible place. The SimpleModel, for example, would only be able to be used in the particular context that it has now been hard-coded into.

    Classes shouldn't know (or care) how they are going to be used, it is not part of their job. The decision as to whether a class should be a singleton or not should be left up to the container (or application).

  2. 2 Posted by Nikos on 16 Aug, 2010 11:07 AM

    Nikos 's Avatar

    I'm with Shaun

  3. Stray closed this discussion on 13 Feb, 2011 04: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