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

Show Posts

* | |

  Show Posts
Pages: 1 [2] 3 4
16  Announcements and General Discussion / General Discussion / Re: Popup Window on: January 25, 2009, 08:50:57
Joel, have I ever told you have impeccable taste when it comes to applying solutions as yours with commands. :) If only other people had such great as us! I really want to share examples like these since I think most people don't really find much use for commands but they can prove to be quite helpful in encapsulating logic.
17  Announcements and General Discussion / General Discussion / Re: Popup Window on: January 25, 2009, 11:06:25

Excellent question! I've found it very helpful to have an AbstractMediator that will retrieve any common Proxies required by all mediators for such things like Configuration, Identity, sometimes even a specific entity, etc.

Since I've had projects that require a few PopUps I've found it handy to create an AbstractPopUpMediator which extends the AbstractMediator. All the AbstractPopUpMediator does is define a private getter for the viewComponent property called "popUp" where its cast as an IFlexDisplayObject. On registration I add 2 event listeners for when the popUp is closed or when you mouse down on the outside area of a popup.

In this case I have that code in a base class but when I first did this I would always have it in the PopUp's actual mediator. Either one works well just depends on preference. I had asked awhile back and you were kind enough to respond Cliff about Mediators removing them self from the Facade so in this case I have the popUp Mediator do that which I find simple and easy. I haven't had a need for having that code in a command but a real great need for opening and determining how one is opened with a command.


For windows in AIR I have the same approach regarding a command to open one. I've had a real need for this since I have logic that has to figure out if the window for a VO is already open, if it is just activate it (bring it to the front and set focus) otherwise one needs to be created. In this case the command is called OpenIdeaEditorCommand and my mx:Window component is called IdeaEditor (think exactly like creating a new email with Apple Mail).

My case is that what makes the component unique is the IdeaVO. I use Flex's UIDUtil class and call the getUID(obj) method passing in an IdeaVO instance to make sure I have a unique id for each instance. This is how I register mediators since I use that UID as a name! I check if their is a mediator registered with that name and if there is I know a window is already open (in this case for an existing idea that is being edited) so I send a ACTIVATE_IDEA_EDITOR notification which that Mediator responds too by calling the viewComponent's activate() method.

If the mediator is not registered I know I need to create a new IdeaEditor so that is done in the command as well as creating and registering the new mediator. All event handlers are taken care of within the mediator, not the command! So if you close the window the mediator listens for a close event so it can remove itself from the Facade. Hot! :) Cliff, I showed this at the set of PureMVC presentations at MAX since it is an AIR client I built using PureMVC.

As I've mentioned to you I'd like to do a series of short presentations/recordings for the PureMVC site since I think I've really nailed the Mediator-Component relationship and have some neat examples on how best to use Commands. Also some advice on how to determine what should be an individual component, when to know to use a command, etc.
18  PureMVC Manifold / Standard Version / Re: Documentation up to date? on: January 24, 2009, 07:19:15
No biggie. It's just that it would be best to have consistency but I'm just not sure what is right. Whether its the PureMVC library file or the docs. In the case of the library it does match what seems to be the standards of the Objective C language which is nice. Methods there do tend to start with the word "with". It seems a way to initialize the component.
19  PureMVC Manifold / Standard Version / Re: Documentation up to date? on: January 23, 2009, 06:54:14
Another example would be the Proxy has a withData method rather than setData.
20  PureMVC Manifold / Standard Version / Documentation up to date? on: January 23, 2009, 06:50:34
Installed the editor today and already am coding in Objective C a language I don't know! Man I love PureMVC. :) Going through the documentation and noticed a Mediator is defined with a setViewComponent method but when looking at the actual source for EmployeeAdmin it uses a withViewComponent method. No biggie but wondering what is correct? Will the documentation be corrected to reflect that? Or is the library that is part of the EmployeeAdmin demo old?
21  Announcements and General Discussion / General Discussion / Re: Popup Window on: January 23, 2009, 11:48:49
Hmm, man there really is a ton of different solutions to the same problem because I'm surely doing it different then all of you. :) So figured I'd share what I do since its sooo cool!

I actually use commands to create popUps. I like it and feel the encapsulation is better there then say in a mediator. Plus this gives me the added flexibility of calling it from anywhere. I do the same for new Window's in AIR apps because most of the time these popUps/windows I also need to create using keyboard shortcuts.

My naming convention always starts with the word Open for the command. So if I have an IdeaEditor component (Window) or a VoteOrganizer (PopUp->TitleWindow) I would call the commands as:

  • OpenIdeaEditorCommand
  • OpenVoteOrganizerCommand

I really like this approach since not only do I have that functionality all in one place in case it needs to change but I can have encapsulated the appropriate logic for determining if the window is already opened then I just bring the window to the front or preventing a new popUp to open if one already exists.
22  Announcements and General Discussion / General Discussion / Re: what is the differences between Proxy & Delegate ? on: December 26, 2008, 01:49:38
I never thought of proxies this way but an interesting way to use them. What I have done and feels most familiar is I create a proxy for each entity I'm managing. If I need to manage users I have a UserProxy. If I need to manage comments I have a CommentProxy.

I strongly suggest the use of the Delegate pattern since it can be a useful and yet further abstraction. For example, if you don't yet have a service to interact with, say the service is being built alongside the client, the delegate can work with a dummy XML file. Once the service is setup you can just start hitting the real service by editing that single file! Very handy!

Another suggestion is that from a single service you might be working with different entity data. For example, a directory service might return identities and organizations. If you are in need of managing both it might be useful to treat each individually in IdentityProxy and OrganizationProxy but then have a DirectoryDelegate which houses the service object for interacting with the directory service. Another handy reason to use a Delegate!
23  Announcements and General Discussion / Architecture / Re: Proxy Calling Proxy on: November 10, 2008, 11:19:31

Did you end going with the second option? I wanted to ask about it if you did to see if you could share a bit more about how you went along with it. Why would you need to dynamically register a command for handling each result? I'm kind of in a similar situation in the sense that each call can go on its own but I need to handle when they are all completed. Curious how you are handling this.

I'm thinking about on each of my proxies having a simple "dataLoaded" boolean (read-only) that the proxy sets when data has been retrieved. Luckily for me the data is read-only and only needs to be loaded once. So I'm thinking about registering a CheckInitialDataDependenciesCommand that would retrieve each of the proxies every time one of the service calls completes. This way in that one command when all have finally completed it will do the next step, in this case firing off another command.
24  Announcements and General Discussion / Architecture / Proxy and Delegate: Parsing data result, who does it? on: October 29, 2008, 05:44:23
I've feel like I have a spot on handle on the view component and mediator relationship but I know I could use some more practice/experience with the C and M portions of PureMVC. I'd like to talk about using Proxies and Delegates and who's responsibility it is to parse the result data and prepare the data for submittal to the service.

At my job we build lots of Flex clients for XML based REST services so we are consuming XML all the time and it does change frequently enough (services having new API versions). I really would like this to be properly handled by a class so I have one place to go to make changes. My problem though is I use both Proxy and Delegate classes and unsure of who's responsibility that is.

I've seen others talk about this in the Cairngorm world but PureMVC is different so the same won't necessarily apply. If I'm exposing methods on a proxy that make service calls, since I use a delegate which hides what type of service is being used should my delegate be handling the result/fault and appropriately parsing the return data? In this case XML. The problem I see with that is now I have so much more work to do as a method on my Proxy will have result and fault handlers and so will my Delegate's equivalent method.

Is this the job of the Proxy class? I guess that would make sense since from reading the docs its meant to hide knowledge of where the data comes from and goes to, from the rest of the application. Delegates are complimentary and not necessary and maybe that's where my error is. Probably seeing this used in Cairngorm is confusing me.

It seemed to me the Delegate class was meant to completely abstract out the service so if you went from an XML service to a JSON one or even to remoting you would only have to change your Delegate class, assuming you are doing your data handling there as well. But maybe this is why we have the Proxy? Was the Proxy meant to take its place?

Hoping for some direction and input. Thoughts?
25  Announcements and General Discussion / Architecture / Re: Where to put processing code for loaded xml resource data on: October 29, 2008, 05:32:35
I definitely recommend considering a parser for your XML. If you are dealing with services that you don't build yourself, and regardless of that, they are prone to change. I wouldn't suggest passing XML around as now your app is very tightly coupled to that XML and if it changes... well that gets messy. :)

At my job we are building a platform so we have lots of RESTful services and rich clients that consume them. By having the parsing for that XML abstracted into its own area and using VO classes its easier to make changes as well as also having strong typing.
26  Announcements and General Discussion / Architecture / Re: AsyncCommands - Proxy or Command handler parses/processes data? on: October 21, 2008, 01:39:50

Thanks for the reply! Appreciate your 2 cents although I feel its worth much more. :)

I've always had my service calls in my proxies but sometimes can get a bit out of hand. I noticed rarely ever having any commands and I liked the approach of having it in a command. I decided on this project to give it a shot.

With this though I realized my proxies don't really do much at all. From there I wondered if best to do parsing in the command but the parsing and setting properties or so coupled. I'll go with your suggestion. I figure the parsing is so data related that is the proxies responsibility so best to do that there.
27  Announcements and General Discussion / Architecture / AsyncCommands - Proxy or Command handler parses/processes data? on: October 21, 2008, 12:40:02
In a current Flex/AIR project I figured I'd try a different approach within PureMVC than what I'm used too. I've created commands that make remote service calls and contain event handlers for fault or result events. If an asynchronous command receives a JSON result, should that handler have the responsibility of parsing the JSON and setting the necessary properties of your data objects or should that be the responsibility of the proxy?

I've always had all this functionality in my proxies but with this different approach I'm curious how others might be handling this. Do your commands know a lot about the model? Do they pull an object from an ArrayCollection, update the properties on that object? Or do you have your proxy parse the data returned (JSON, XML, etc.) to update the model?

28  Announcements and General Discussion / Architecture / Re: Multiple instances of the same mediator/proxy? on: October 21, 2008, 12:35:53

If I may suggest a better approach. The problem I've had with appending the name to the id is its just not flexible enough. Imagine a multiple instance of the same mediator and proxy for a dynamically created component. If I have an id with the name containing "mediator" and if I'm sending a notification from the proxy I will have to parse out "proxy" from the id and add "mediator" within the name so that way my mediator correctly responds to the notification. Way to much work.

I have written a post on the forums regarding this approach in detail. I've had to do a lot of dynamic stuff in my Flex projects and since I use PureMVC I've done this several times. I've had several of the same questions as you. Hope the post helps out. You can find it at: http://forums.puremvc.org/index.php?topic=596.0

Let me know if you have any questions.
29  Announcements and General Discussion / General Discussion / Re: How to manage notifications? on: October 15, 2008, 07:56:12

I could see the framework simply using a logger class to log this sort of information. Would this be sufficient are you are looking for something a bit different? I'm thinking this sort of output would be similar to say the Model Glue framework in CF where it implements a trace() function just like in Flash, but it by default will also trace debug whatever the framework is doing so you can see what is happening in what order. I know you have some experience with CF so I bring this up as an example to see if its suitable. I'd be happy to work on this.
30  Announcements and General Discussion / Architecture / Re: AsyncMacroCommand (with a ChainNotifier style Mediator) on: October 15, 2008, 07:45:57

Hate to bother but the weekend has come and gone. Any status on the async command utility being available for download? I'd be happy to help test it out if you aren't sure yet about putting it up publicly. Let me know. Thanks!
Pages: 1 [2] 3 4