Skip to content

Instantly share code, notes, and snippets.

@Stray
Created November 16, 2010 11:06
Show Gist options
  • Save Stray/701701 to your computer and use it in GitHub Desktop.
Save Stray/701701 to your computer and use it in GitHub Desktop.
Nosy mediators (or mediator-mini-controllers) open the view's mail
// Good mediator behaviour:
function handleDataEvent(e:DataEvent):void
{
var userVO:UserVO = e.userVO;
view.showUsername(userVO.firstname, userVO.surname);
view.showAge(userVO.age);
view.setStatus(userVO.isSaved);
}
// Nosy mediator behaviour (in this case it also uses an injected model)
function handleDataEvent(e:DataEvent):void
{
var userVO:UserVO = e.userVO;
if(userVO.age < 10)
{
view.showKindergartenLayout();
}
else
{
view.showNormalLayout();
}
if(userVO.country != 'US')
{
var countryColours:Array = countriesModel.getCountryColoursListFor(userVO.country);
view.useColourSet(countryColours);
}
}
@joelhooks
Copy link

I'm in the congregation! Mediators route. Anything else is beyond scope for me.

@Stray
Copy link
Author

Stray commented Nov 17, 2010

Excellent! Yes - keep it simple for each class and you only have one problem - how the classes work together. With mixed-purpose classes you've got two levels of headaches. In the classes AND between the classes. Ick :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment