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]
Author Topic: Where to put the various constant names for Notifiers  (Read 2941 times)
Jr. Member
Posts: 10

View Profile Email
« on: July 29, 2008, 08:55:59 »

Hi there,

After recently getting to grips with PureMVC and building a couple of test apps, I'm diving in to using it for a larger application. It'll be a Flex app with multiple modules (using Pipes), and I've got the structure worked out quite nicely as I'd like it.

In my test apps, I've tended to create a class which purely exists to define all the Notification name constants, so that any class that needs to send a notification, or react to one, can gather the constant name from this one class. I decided not to put them in the ApplicationFacade to keep that class nice and simple. This has been working pretty well for me, but I'm wondering if it's 'Best Practice'?

Obviously, I'm gonna need one of these constant-storing classes per Module, and the fact that I'm using Modules is really irrelevant to my question. I'm interested to know what people have done when building larger apps with the framework - are you tending to keep everything inside ApplicationFacade? Are you creating a class just to store all the constant names? Are you doing something else which I hadn't considered?

Any info would be much appreciated.
Posts: 6

View Profile Email
« Reply #1 on: July 29, 2008, 12:05:49 »

I think this is a good idea generally speaking.  I started to do it this way, but since many of the classes that need to send and receive notifications already had ApplicationFacade imported, I found it a pain to have to add the Notifications import.  This is really just because Flex builder is lame (or maybe I am), and command + shift + o doesn't seem to work (but type ahead with code assist does work).

I have all my notifications starting with a prefix.  Mine is AEV_ for "application event".  This helps with search and replace and finding things.  If you have something like "login" you will find it everywhere.  Again, this is also because the Flex builder sucks for re factoring and misses things all the time. 
Global Moderator
Hero Member
Posts: 2871

View Profile WWW Email
« Reply #2 on: July 29, 2008, 07:52:57 »

@andrew - organize imports works to remove unneeded imports and to sort the rest, but doesn't add missing ones. For that, place the cursor right after a class or interface name (like Notification or INotification) and press  ctrl space to add the import.

@toby sure put you shared constants in a separate file if you like. The ApplicationFacade is just a handy place within an app.

With MultiCore, if you want to share constants across modules, you can put a constants file into a separate API library project referenced by each module and the main app, so as not to form dependencies between app and module or module and module.


Pages: [1]