Created
November 16, 2010 11:06
-
-
Save Stray/701701 to your computer and use it in GitHub Desktop.
Nosy mediators (or mediator-mini-controllers) open the view's mail
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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); | |
| } | |
| } |
Author
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
I'm in the congregation! Mediators route. Anything else is beyond scope for me.