Futurescale, Inc. PureMVC Home

The PureMVC Framework Code at the Speed of Thought


Over 10 years of community discussion and knowledge are maintained here as a read-only archive.

New discussions should be taken up in issues on the appropriate projects at https://github.com/PureMVC

Pages: [1]
Print
Author Topic: True or False? Not good pratice to have import org.puremvc* in Mediators  (Read 6352 times)
jgervin
Courseware Beta
Sr. Member
***
Posts: 50


View Profile Email
« on: March 10, 2009, 02:48:40 »

Is it true that you should not have references to other mediators from medicators?  Thus, if you are import org.puremvc * in your mediators you are doing something wrong?

Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #1 on: March 10, 2009, 04:39:09 »

Though you can retrieve a mediator and manipulate it directly, its best to send notes between them instead to keep unnecessary couplings to a minimum.

However, mediators often need to create other mediators and so may need to be able to instantiate them. For instance, an ApplicationMediator generally takes reciept of the sole lasting reference to the main application view hierarchy. This mediator will then generally 'snap off twigs' of the view tree and hand them to new mediators which it creates and registers. This may happen recursively with those newly registered mediators immediately or at a deferred time registering new mediators for the children of their view components.

That's the scoop on mediator to mediator interaction, however your mediators ar usually all in the same package with each other and so don't need imports to see each other. And that package wouldn't be org.puremvc, but more like com.myapp.view.*

And on the subject of using * for import; irregardless of what framework you use (if any), using the glob is a bad idea. Not because the classes would all be compiled in, they won't, the reason is  maintainability. When someone looks at a class the imports tell the story of what the classes actual collaborators are. With globbing, you have no idea unless you inspect all the code. If you are using FlexBuilder/Eclipse, a Ctrl-shift-O will do an 'Organize Imports', sorting them and discarding unused imports. Teach your fingers this immediately. Every time you save a class - always organize imports by rote. Even if you haven't dropped a class or added one.

If you aren't lucky enough to have this feature in your environment, then be diligent about manual organization. Its worth the effort.

-=Cliff>   
Logged
houen
Newbie
*
Posts: 5



View Profile WWW Email
« Reply #2 on: March 11, 2009, 01:57:14 »

Flex builder is a really nice tool to work with in my opinion. If you are working in a company, they'd be idiots not to shell out the few bucks for that or FDT, and if you are a student you can get it for free for educational purposes:
http://www.adobe.com/devnet/edu/
Logged

My sites:
Flash Game site: www.999credits.com
Blog: www.houen.net/blog
Pages: [1]
Print