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]
1  Announcements and General Discussion / General Discussion / Presenting at Adobe MAX 09 on PureMVC on: August 19, 2009, 11:17:13
I'm very excited to announce that Cliff has recommended me to present on PureMVC at Adobe MAX this year at the Flex Frameworks session which will also include Mate, Swiz, and Cairngorm. He's not able to make it this year but I'm happy to take his place and represent an excellent framework and community at MAX! I love presenting so I'm hoping to give a great impression on PureMVC!

I really want to include everyone's feedback into my presentation. I'm currently on vacation but I will be planning it out as I have a strict time limit of 45 minutes and its supposed to be a hands on session. I'd like to ask you guys a few questions to help me organize what parts I cover and in what order.

Again note that this will be a near complete hands on session so all of the questions asked below are in regards to having the attendance code out the sample application.

  • What part of PureMVC do you find the hardest to understand?
  • If you were introduced the parts of PureMVC (mediator, facade, etc) what order do you think is appropriate?
  • What piece (mediator, facade, etc) do you think should be covered more thoroughly over others? This will have a great affect as there is a time limit of 45 mins.
  • Anything you'd like me to share about the community? I personally think this is one of PureMVC's strongest areas
  • Are their particular points from the PureMVC Best Practices documentation that you feel should be in the presentation?
2  Announcements and General Discussion / Architecture / Handling Async Startup Data Dependencies on: April 06, 2009, 06:22:30
I'm curious if anyone here has any utilities or approaches they use to handle loading data dependencies at startup. By that I mean making any service calls and waiting for them to complete before any interactions with the app can take place. I use the AsyncCommand utility in my app but its not what I'm looking for in this case since I'm loading dependencies in parallel (not in sequence, each call isn't dependent on one another).

Currently, what I do is have a command called CheckDataDependenciesCommand that fires any time one of those service calls completes. This is nice and simple but I need to handle failures and would like to enable retrying a service call a number of times if it has failed. I'm thinking my simple approach won't really do the trick and maybe a utility is better suited.

Thoughts or suggestions?
3  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?
4  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?
5  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?

Thoughts?
6  Announcements and General Discussion / Architecture / AsyncMacroCommand (with a ChainNotifier style Mediator) on: October 03, 2008, 12:14:16
I've looked at the ChainNotifier http://forums.puremvc.org/index.php?topic=422.0 but its not necessarily what I expected. I've been wanting an approach that follows more the PureMVC flow, API... not sure what word I'm looking for here. Looking for something that feels PureMVCish.

@cliff, @binarycrafts

I think I have an idea that will solve some of your concerns that you mentioned in the ChainNotifier utility topic (link above).

I envision say.. an AsyncMarcoCommand, that would implement ICommand and INotifier that you call addSubCommand for each asynchronous command you wanted fired in order. Now before you all cry foul let me explain the handling for these sub commands!

Using something similar to the ChainNotifier, the AsyncMacroCommand would add each sub command to an instance of a AsyncCommandMediator (I can't think of a better name at the moment so don't get to caught up on this one!). This is crucial since Cliff makes a good point that the mediator after being registered will have to be de-registered.

How to handle the de-registration? Well with each addSubCommand call you would add in the notification it sends on complete. The AsyncCommandMediator would know (since its listening for all those notifications) when the last notification fires thus being able to remove itself from the framework.

What does this solve?

1. The command won't have state! Yay!
2. Since a mediator is registered it will handle removing itself from the framework when its done
3. Every time you issue a new AsyncMacroCommand it will always register a new instance of AsyncCommandMediator (and safely deregister when all commands are completed)
4. Sticks to the API the PureMVC framework provides for sequencing commands (only now it works with async ones!)
5. Provides a map.. an easy to read sequence of the commands being fired in one place. No more having to go search for each sendNotification call that triggers the next command. Woo hoo!

Brainstorming this just now what do you guys think? Would something like this work? Say the word and R&D will begin!
7  Announcements and General Discussion / Architecture / Alert prompt (with close handler) in a command? on: September 24, 2008, 10:20:07
I know commands are good places to have common actions that need to happen from different views in your app. For example, if you display a pop up based on a keyboard event, a button click and even some other action, abstracting that repeated code into a command is useful. I have a situation where I'm building a desktop application where there is much more communication going on between components and am wondering if a command fits well with what I'm trying to do. Let me explain.

I have a List and AppControlBar component each with its own mediator. When an item is selected the AppControlBar is notified and has a tracker (variable) for that item. A "Delete" button is in the control bar (plus many other item-selected dependent actions) that displays an Alert prompt with Yes/No buttons. Pretty straightforward. The catch is that I've added a key down handler on the List component so if the user hits their DELETE key I want to trigger that same Alert prompt but that is defined within the AppControlBar MXML component.

Is this where I would take that block of code with the Alert prompt and move it into a command? Seems like an easy question but I'm not really used to knowing exactly when to use commands and when not too. My concern here is that the Alert needs a close handler and I know commands shouldn't have state. Would the code for the Alert prompt still go in a command?

Suggestions/Thoughts?
8  Announcements and General Discussion / Public Demos, Tools and Applications / New PureMVC AIR Utility - NetworkMonitor on: August 26, 2008, 01:51:49
I had an idea for a simple PureMVC AIR utility that will send out a notification when your application is offline or online. I'm building my first offline-supported AIR PureMVC application so this is something of value to me. I would love to tap into a notification that is clear and simple: ONLINE or OFFLINE. I can simply register a command with this notification and I can do whatever work necessary when either online or offline. This is the main goal of the utility.

The utility has 2 commands and 1 proxy. The NetworkMonitorProxy to put it simply handles a URLMonitor instance. Once you tell it to start you have no other work to do. No need to add an event listener on NativeApplication.nativeApplication either! The NetworkMonitorProxy will listen for a status event on the URLMonitor instance and using its "available" property determines whether to send an ONLINE or OFFLINE notification. Simple.

Before being able to start the monitor you need to simply register this command:

registerCommand(NetworkMonitor.START_MONITOR, StartNetworkMonitorCommand);

To start the monitor send the following notification with a body being a URL to monitor:

sendNotification(NetworkMonitor.START_MONITOR, "www.myservice.com");

You would follow the same procedures for stopping a monitor with the only difference being sending no body to fire off the command. Also as a helper NetworkMonitorProxy sends out to notifications when a monitor has started NetworkMonitor.MONITOR_STARTED and when it has stopped NetworkMonitor.MONITOR_STOPPED.

Basically all you are going to want to do is handle the following notification constants in your mediators or register it to fire off a custom command: NetworkMonitor.ONLINE or NetworkMonitor.OFFLINE depending on what you need. When these notifications are sent the notification body is the NetworkMonitorProxy instance. I did this since I have several properties you might want access too say for logging or other purposes. Those read-only properties include:

  • online
  • startedOn
  • statusChangedOn
  • url

I couldn't think of anymore to add in but if any of you have ideas let me know. I'd like to see what features you guys might need but I figure since this is pretty simple and straightforward much if not nothing at all else would be needed. I plan to share the code but I'm unfamiliar with procedure of getting a utility out as I would need to change the namespace for PureMVC first.


Cliff,

I've talked to you through email about creating PureMVC utilities and what their namespaces should be. I've completed this utility locally and would love to finally be able to offer something back to the PureMVC community. What do I need to do to get this submitted for approval? Just zip up and send you the code? Commit it to an SVN repo you create? Let me know.
9  Announcements and General Discussion / Architecture / Registering Multiple Instances of one Mediator and Proxy: A Best Practice on: July 30, 2008, 09:49:26
Say you have an application where you manage users. You provide a multi-tasking UI, using flexlib’s SuperTabNavigator to provide multiple tabs with each tab representing a user. Maybe its a form where they can edit that data or simply view it. You could expect to have at least the following classes:

  • User (MXML component)
  • UserVO
  • UserProxy
  • UserMediator

Now the problem becomes that you need to create multiple instances of these objects and register the proxies and mediators dynamically with PureMVC. Another problem is when one of these objects sends a notification that is specific to that instance it you need a way to ‘tag’ it. I’ve been using the notification’s type property for that. Cliff Hall and others have suggested the same.

 I figured setting and defining a best practice for consistency would help others. Let me describe what I have been doing in my PureMVC projects to achieve this in a clean, productive manner.

First I need to allow the constructor of a mediator and a proxy to take a dynamic name. The constructor would take the NAME constant as a default but you would always override it. So I would setup a UserProxy like this:

:
/**
 * Constructor.
 */
public function UserProxy(proxyName:String=NAME)
{
super(proxyName, new UserVO());
}

This way I can provide a unique name. The same applies to a Mediator. Next I would create an implicit getter to abstract the call to getMediatorName() or getProxyName().

:
//--------------------------------------------------------------------------
//
//  Properties
//
//--------------------------------------------------------------------------

//----------------------------------
//  id
//----------------------------------

/**
 * The proxy's unique id. This is a dynamically registered proxy.
 */
public function get id():String
{
return getProxyName();
}

The same code above applies to a Mediator. This provides for a consistent name and doesn’t have your proxy or mediator littered with getMediatorName() or getProxyName() calls whenever you are sending notifications.

Now for the actual creation of the objects I would have a command take care of that, this way its easily reusable and the all object registrations are in one place. Nice! As an example I would have a command named CreateUserEditorCommand and it would look this:

:
/**
 * Create a new User editor with its own mediator and proxy and then
 * we send a notification to add it to the set of tabs.
 */
override public function execute(note:INotification):void
{
var uid:String = UIDUtil.createUID();

var user:User = new User(); // this is our MXML component
user.label = "Cliff Hall";
user.id = uid;

facade.registerProxy( new UserProxy( uid ) );
facade.registerMediator( new UserMediator( uid, user ) );

sendNotification(ApplicationFacade.ADD_EDITOR, user);
}

The User instance is our MXML component (our editor tab) and if you look carefully I’m setting its id property to a unique identifier. I use the UIDUtil class (part of the Flex framework) to make sure I always have a unique id. The reason I set it on the MXML component is this way I have access to it there. This might not be needed.

I’m not sure if ‘id’ is the best name to be used here and hoping to get suggestions from all of you. I’ve talked about this approach with my fellow employees and they like it.

I had a suggestion from our Flex team leader to use the ‘name’ property instead of ‘id’ on the MXML component especially since Flex uses ‘id’ internally. I figured if I’m setting it with something unique though it shouldn’t be a problem. I have been considering instead using ‘name’ as the implicit getter on the mediator and proxy and on the MXML component.

Thoughts?

If this generates interest I’ll share how I register sub proxies and mediators as well as a command to clean up these dynamically registered actors.
Pages: [1]