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 / ActionScript Developers Guide to PureMVC on: December 28, 2011, 08:16:48
I started reading the e-book a few days ago, and as I usually do with other books as well, I skipped the Preface, anxious to get to the core of the matter. But I was also curious to see how the application works and spent a lot of time going through the code, then running the app and clicking all the buttons before really knowing what they were supposed to do. This way I found a little bug and later a temporarily fix for it. Looking at the code, without reading the accompanying explanations from the book, allowed me to get an uninfluenced first impression: well structured (good hierarchy of packages), self explanatory variables, methods, classes, and packages names, helpful comments throughout the code.
I got a general idea of the responsibilities of the classes, and even though the code is pretty complex, I could identify the repeating behavioural patterns or the intended functionality.
 
I was glad that I found something not working as expected, because, in trying to find the bug, I got involved in the details of the code, which in turn, allowed me to better understand the logic behind some classes and methods and the relations/collaborations between them. I switched from a passive observer to an active investigator (err.. something like that)
Then, when I continued reading the book I was pleasantly surprised to find that each class discussed in the book was accompanied by a description of its responsibilities and collaborations! This way I could easily verify my understanding of the code. Im not done reading yet, but with every page in the book the haze keeps dispersing and the contours of the app are becoming increasingly clear. From what Ive seen so far in the book I like that the main focus is put on

a.   the boundaries of the application , domain logic and views
b.   the process of planning,  architecting the app, the steps described
c.   responsibilities and collaborations of a classes

Because of that it is an almost framework-independent approach, which is a really good thing, especially in the light of today's rapid changes in our world of software development or technology in general.


My initial intention was to share my opinions first after reading the entire book. But yesterday, when I wanted to continue reading it, instead of going to chapter 5, I started from the beginning, absent mindedly flipping through pages, and...well.. no one saw me, but Im sure that the huge surprise made me look utterly funny when I stumbled upon the mention under Collaborations!
First of all, I want to thank you, Cliff! I know it wasnt easy to decide who to put on that list or rather who to omit. I dont think that what I did or said in here could be considered as a contribution at all. There are others whove contributed more substantially to the framework or the community, so what I did was infinitesimally small in comparison with their work. Since yesterday Im having mixed feelings of joy and a kind of guilt at the same time, because I think I didnt really deserve to be mentioned.
So, to correct the situation let me put it in another light: in an open source project like this everyone is part of the project. Every single answer, every demo, example, shared code, and/or utility is a contribution to the project.
Even every question asked on a forum, even if it has been asked before zillions of times, is a valuable resource for learning, or for identifying the weakness of a project, or for seeing a large variety of use cases, or just for keeping your mind alert and fresh, in a state that Id like to call Beginners Mind (keeping oneself free from preconceived ideas, open to dialog).
In this light, mentioning someone like me as a contributor is a very considerate and compassionate gesture, and it is a proof of fairness. But I want to take it rather symbolic than personal, meaning that I represent all the others users who thought their contributions were insignificant. In fact it is a matter of interweaved efforts/actions/nodes where the single nodes can weigh more or less, but without them there wouldnt be a net.
In other words:
-   an open source project is a collaboration of many minds, more or less great, more or less perceptible
-   contributing to an open source project in any form or way is rewarding, the more so when you dont expect it or when your actions werent driven by it
-   the process of learning goes two ways: from the advanced users to the beginners and back

I could continue with my interpretations about open source projects, but Im aware of the fact that such a discourse sounds a little pathetic ;-)

So, Id better go back to talking about the bugs, of course only if you want me to and if this forum is the right place for it. As I said I found a solution, not sure yet if it is the right one, because Im still in the process of understanding the code and its overall logic and maybe later Ill see another way to achieve the same. Let me know if you want to see it (its a gist on github)


Cheers,
Ondina
2  Announcements and General Discussion / General Discussion / Memory management and garbage collection on: June 30, 2009, 01:00:18
Memory management and garbage collection - the big deficiency of the FlashPlayer

It seems that many of us are struggling with this issue, so I thought it would be good to share my findings after  my  (desperate) research into this subject.

Here some links to articles, that I found to be somehow useful, even if none of them is giving the ultimate answer to (Flex and AIR) developers' prayers:

1
http://gskinner.com/talks/resource-management/
http://www.gskinner.com/blog/archives/2006/06/as3_resource_ma.html
http://www.adobe.com/devnet/flashplayer/articles/garbage_collection.html

2
http://office.realeyesmedia.com/blogs/jun/?p=61
http://office.realeyesmedia.com/blogs/jun/samples/360Flex/360_Slides/index.htm

3
http://blogs.adobe.com/aharui/2007/03/garbage_collection_and_memory.html
http://blogs.adobe.com/aharui/2008/09/using_the_flex_builder_3x_prof.html

4
http://blog.flexmonkeypatches.com/2007/03/28/flash-player-memory-management-and-garbage-collection-redux-2/

5
http://www.insideria.com/2008/03/flex-performance-memory-manage.html


6
http://www.craftymind.com/2008/04/09/kick-starting-the-garbage-collector-in-actionscript-3-with-air/

7
http://elromdesign.com/blog/2008/03/15/boost-flex-performance-with-object-pooling-manager-api/

8
http://flex.sourceforge.net/manual/The-Default-Memory-Management.html#The-Default-Memory-Management

9
http://roshantitus.blogspot.com/2008/11/flex-memory-management.html

10
http://www.nutrixinteractive.com/blog/?p=132


11  Flash Player Mental Model - The Elastic Racetrack <-interesting
http://www.onflex.org/ted/2005/07/flash-player-mental-model-elastic.php

Does anyone know of any other articles on that subject?

Ondina
3  PureMVC Manifold / MultiCore Version / PureFormSubmission - Deferred Instantiation, StateMachine on: June 17, 2009, 12:12:36
While trying to understand the StateMachine I've followed the instructions on PureMVC TV
( http://puremvc.tv/ )
and made a (very simple) FormSubmission application.
The app is also illustrating my experimenting with the deferred instantiation and the registration of puremvc mediators.
It is not a demo, so it is not commented at all.
There are 3 Views containing form-fields.(One, SubOne, SubTwo)
The data will be collected from all 3 forms when the user presses the submit button..

Feedback from the puremvc gurus, experts or anyone else would be much appreciated, especially because I'm still in the process of learning how to use the StateMachine  and therefore I need   suggestions for better solutions.

http://sites.google.com/site/mvc4flex/Home/pureformsubmission
PureFormSubmission.swf  (demo)
PureFormSubmission.zip  (source)
http://code.google.com/p/ondina-air-flex-pmvc/source/checkout (source)

Ondina
4  Announcements and General Discussion / General Discussion / PureMVC TV on: June 11, 2009, 02:12:54
It might be a good habit for the users of this forum to take a look at  the “Home” (http://puremvc.org/component/option,com_frontpage/Itemid,1/) section of this website from time to time. There you can find interesting and useful announcements and info, such as the one about  the http://www.puremvc.tv/  project.

Cliff, I don't know which word to use to better describe that project and its future capabilities. I could just say: GREAT. But it wouldn't be enough, so I suggest you think of all the positive(good) superlatives, and  all of them would do a good job in describing the content and the value of the project.
I'm very impressed and thankful.

Ondina
5  Announcements and General Discussion / General Discussion / Wolfram|Alpha on: May 16, 2009, 12:50:06
“Wolfram|Alpha just went live for the very first time, running all clusters.”
http://www.wolframalpha.com/

I thought that someone who is interested in design patterns might as well want to know about WolframAlpha, the answer-engine.
It doesn't know anything about pureMVC yet ...:)

Ondina
6  PureMVC Manifold / MultiCore Version / Desktop Citizen Event.CLOSING on: March 19, 2009, 03:43:05
Hi Cliff

Desktop Citizen is great. Thanks again for this utility.

I would like to be able to prevent an accidental closing of the WindowedApplication and ask the users if they want to save the data before exiting the application.

In the WindowMediator of the utility there is:
 
stage.nativeWindow.addEventListener( Event.CLOSING, onWindowClosing );

and the method

protected function onWindowClosing( event:Event ):void

I can have a modal dialog  asking the users if they want to exit or not, if I modify it like this:

private var isWorkSaved:Boolean = false;
protected function onWindowClosing( event:Event ):void
{
if( !isWorkSaved )
   {
       event.preventDefault();
       Alert.show( "Would you like to save your work?", "Warning!",Alert.YES | Alert.NO, null, onAlertClose );
        }
}            
protected function onAlertClose( event:CloseEvent ):void
{
   if( event.detail == 1 )
   {
       isWorkSaved = true;
      stage.nativeWindow.visible = false;
      sendNotification( WindowCloseCommand.NAME );
      stage.nativeWindow.close();
   }
}

or I can send a notification inside the  onWindowClosing and have the modal dialog in my application somewhere and then from there sendNotification( WindowCloseCommand.NAME );

I don't know if it's ok with you if  I'd change it like this (copyright license?), but event if it was, isn't there another (better) way to achieve the same when I use DesktopCitizen   And also maybe in other situations I don't want to  have that modal dialog before exiting the application.

Ondina
7  PureMVC Manifold / MultiCore Version / MultiCore + AIR + resize window on: February 27, 2009, 04:23:59
I'm 7 days old (puremvc time).
So I still know/remember what newbies go through when trying to use this (or other new) framework in their projects and I thought that before leaving (some day..) the puremvc-kindergarten I could tell the newbies coming after me how  to play with the coolest puremvc-toys.

I took the CodePeek example and simplified it and made it run under the MultiCore version.
Maybe there is such an example already, but I didn't find it even after in depth search. If the post isn't useful or if it is redundant you (moderators) can delete it.
I don't know if everything is correct in my code below but it works.

MultiAir
libs
   PureMVC_AS3_MultiCore_1_0_5.swc

   Utility_AS3_MultiCore_AIR_DesktopCitizen_1_2_1.swc
   (This utility provides the ability for PureMVC-based AIR applications remember their window size, position and maximized state each time it is launched. )

src
      org.controller
      StartupCommand.as
org.view
   components
      AppControlBar.mxml
   AppControlBarMediator.as
   ApplicationMediator.as
ApplicationFacade.as

   MultiAir.mxml
------------------------------------
MultiAir.mxml (main)

<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml"
   xmlns:view="org.view.components.*"   
   applicationComplete="facade.startup(this)"
   layout="absolute"
   >
   <mx:Script>
      <![CDATA[
         import org.ApplicationFacade;
         // App name
             public static const NAME:String = "MultiAir";
         // Initialize the PureMVC multicore-apparatus
             private var facade:ApplicationFacade = ApplicationFacade.getInstance( NAME );
             [Bindable] public var showControls:Boolean = false;    
      ]]>
   </mx:Script>
   <!-- The Application Control Bar -->
   <view:AppControlBar id="controlBar"/>
   <mx:TextArea x="10" y="10"  width="250" height="250"/>
</mx:WindowedApplication>

------------------------------------
ApplicationFacade.as

package org
{
   import org.puremvc.as3.multicore.utilities.air.desktopcitizen.DesktopCitizenConstants;
   import org.puremvc.as3.multicore.utilities.air.desktopcitizen.controller.WindowOpenCommand;
   
   import org.puremvc.as3.multicore.patterns.facade.Facade;
      
   import org.controller.StartupCommand;
   import org.controller.ShutdownCommand;

   public class ApplicationFacade extends Facade
   {
      // Notification name constants
      public static const STARTUP:String            = "startup";
      
      public function ApplicationFacade( key:String )
       {
          super(key);   
       }
       
        public static function getInstance( key:String ) : ApplicationFacade
        {
            if ( instanceMap[ key ] == null ) instanceMap[ key ]  = new ApplicationFacade( key );
            return instanceMap[ key ] as ApplicationFacade;
        }
   
      public function startup ( app:MultiAir ) : void
      {
         sendNotification( STARTUP, app );
      }
         
      override protected function initializeController () : void
      {
         super.initializeController();
         registerCommand( STARTUP, StartupCommand );
      }   
   }
}
--------------------------------------------
StartupCommand.as

package org.controller
{
   import org.puremvc.as3.multicore.interfaces.*;
   import org.puremvc.as3.multicore.patterns.command.*;

   import org.view.*;

   import org.puremvc.as3.multicore.utilities.air.desktopcitizen.DesktopCitizenConstants;
   
   /**
    * Create and register <code>Proxy</code>s with the <code>Model</code>.
    */
   public class StartupCommand extends SimpleCommand
   {
      override public function execute( note:INotification ) :void   {
         
         var app:MultiAir = note.getBody() as MultiAir;
         
         facade.registerMediator( new ApplicationMediator( app ) );
         sendNotification( DesktopCitizenConstants.WINDOW_OPEN, app.stage );
      }
   }
}
-------------------------------------
ApplicationMediator.as

package org.view
{
   import flash.events.Event;
   
   import org.puremvc.as3.multicore.interfaces.*;
   import org.puremvc.as3.multicore.patterns.mediator.*;

   import org.ApplicationFacade;
   import org.model.*;
   
   import org.puremvc.as3.multicore.utilities.air.desktopcitizen.DesktopCitizenConstants;

   public class ApplicationMediator extends Mediator implements IMediator
   {
      // Cannonical name of the Mediator
      public static const NAME:String = 'ApplicationMediator';
      public function ApplicationMediator( viewComponent:Object )
      {
         // pass the viewComponent to the superclass where
         // it will be stored in the inherited viewComponent property
         super( NAME, viewComponent );
      }
      public function get app():MultiAir{
         return viewComponent as MultiAir;
      }
      override public function onRegister( ):void
      {
         facade.registerMediator( new AppControlBarMediator( app.controlBar ) );
      }
      override public function listNotificationInterests():Array
      {
         return [ DesktopCitizenConstants.WINDOW_READY];
      }
      override public function handleNotification( note:INotification ):void
      {
         switch ( note.getName() ) {
            
            // Time to show the application window
            case DesktopCitizenConstants.WINDOW_READY:
               app.showControls = true;
               break;
         }
      }
   }
}

-----------------------------------------
AppControlBarMediator.as

package org.view
{
   import org.puremvc.as3.multicore.interfaces.*;
   import org.puremvc.as3.multicore.patterns.mediator.*;

   import org.ApplicationFacade;
   import org.view.components.AppControlBar;
   
   /**
    * A Mediator for interacting with the AppControlBar component.
    */
   public class AppControlBarMediator extends Mediator implements IMediator
   {
      // Cannonical name of the Mediator
      public static const NAME:String = 'AppControlBarMediator';
      
      public function AppControlBarMediator( viewComponent:Object )
      {
         super( NAME, viewComponent );
      }
      protected function get controlBar():AppControlBar{
         return viewComponent as AppControlBar;
      }
   }
}
---------------------------------
AppControlBar.mxml

<mx:ApplicationControlBar xmlns:mx="http://www.adobe.com/2006/mxml" dock="true">
   
   <mx:Script>
      <![CDATA[
      import org.ApplicationFacade;

      public static const BEGIN_CODE_SEARCH:String    = "beginCodeSearch";
      public static const CANCEL_CODE_SEARCH:String    = "cancelCodeSearch";
      
      [Bindable] public var comboOptions:Array;
      [Bindable] public var searching:Boolean = false;      
      
      /**
       * Initiate Code Search.
        */
       private function search() : void
       {
          searching=true;
           dispatchEvent( new Event( BEGIN_CODE_SEARCH ) );
       }
           
      /**
       * Cancel Code Search
        */
       private function cancel() : void
       {
          searching=false;
           dispatchEvent( new Event( CANCEL_CODE_SEARCH ) );
       }
           
      ]]>
   </mx:Script>
   
   <!-- The Search Controls -->
   <mx:HBox width="75%">
      <mx:ComboBox id="searchCombo" dataProvider="{comboOptions}" close="searchTI.setFocus()"/>
      <mx:TextInput id="searchTI" width="250" toolTip="Enter a language keyword or code fragment." enter="search()"/>
      <mx:Button label="Search" click="search()" enabled="{(searchTI.text.length != 0)&amp;&amp;(!searching)}" />
      <mx:Button label="Cancel" click="cancel()" visible="{searching}" />
      <mx:Label text="Searching..." fontFamily="Courier" fontSize="10" visible="{searching}"/>
   </mx:HBox>      
</mx:ApplicationControlBar>
--------------------
N.B. I took out the long comments for  readability's sake.

Ondina
8  Announcements and General Discussion / General Discussion / PopUps again on: February 26, 2009, 09:57:53
I found these posts related to how to manage a PopUp, that provide examples:

http://forums.puremvc.org/index.php?topic=105.msg367#msg367
--
http://forums.puremvc.org/index.php?topic=257.0
with this  link to an example:
http://www.lfpug.com/presentations/2008_01_31_keane/ApplicationConfigExample.html
--
http://forums.puremvc.org/index.php?topic=995.0
with this link to an example
http://www.nutrixinteractive.com/blog/?p=329
--

Do you know which one has the better solution in the context of puremvc?


Thanks, Ondina
9  Announcements and General Discussion / Getting Started / Steps to follow on: February 24, 2009, 09:27:07
Hello

I've been reading many posts on this forum,  tutorials/articles and the FAQ section  for the last 3 days.  I'm more and more inclined to use puremvc for my project.  Actually I'm already rethinking my specific use cases from the puremvc perspective and as far as my theoretical knowledge about the framework goes it seems to be able to solve my problems.
Now my project is very complex and refactoring it is not easy, especially because I have to do it fast.  Not that I am in a hurry, but the customer is. I bet you know what I mean.

I'm wondering if it's the right approach to get help from you  if I'd post a list of my questions regarding the project's architecture and you would point me to the place where the same questions were answered already?

Or  is it better to stick to one specific question  per post?

The best way for me would be if I could show you an approximate structure of my project and mark the problematic parts, for example in form of a diagram like the ones below and then instead of a lot of words describing what I wanted you could see it immediately on a diagram.

I don't know if it's ok to post images, but since the text editor on this forum allows it I thought I could try. These were my first steps on the way of understanding puremvc:

see attachment 1
see attachment 2


Now this was a very simplified scenario with a one-way flow without response(client->server), but did I get it right so far?

I'm sorry if I'm too intrusive.

Thanks, Ondina

N.B. I don't want to call Cliff.
10  Announcements and General Discussion / Getting Started / Does the frame work? on: February 23, 2009, 07:37:55
I am new to this framework. Just saying hello, while reading the posts on the forum and trying out the examples.

Currently I am trying to decide which one of the most popular (Flex) frameworks is more suited to satisfy my project's needs. Not an easy job, I must say.

After much reading and trying the widely known “Cafetownsend” example (and others) in the different (frameworks)variations my current state of mind is something similar to the excerpt from

Design patterns explained by Alan Shalloway and James R. Trott

<<
....
According to the Gang of Four, the intent of the Bridge pattern is to  “De-couple an abstraction from its implementation so that the two can vary independently.”

I remember exactly what my first thoughts were when I read this:
Huh?
And then,
How come I understand every word in this sentence but I have no idea what it means?!

I knew that
• De-couple means to have things behave independently from each other or at least explicitly state what the relationship is, and
• Abstraction is how different things are related to each other conceptually.
And I thought that implementations were the way to build the abstractions; but I was confused about how I was supposed to separate abstractions from the specific ways that implemented them.
......
>>

The first impressions about PureMVC:

-its  portability is very attractive. Right now I'm working on an AIR project, but  some month from now I might be working on a web project using AJAX and PHP, or maybe just Flash.
-the community seems to be very active and there are some interesting contributions coming from the members
-the FSM implementation,  Startup Manager utility, Pipes are very appealing, as far as I understood them from their description and demos
-the showcase section is encouraging for beginners, meaning that someday somehow they will be able to do it alike or that the framework is old enough to be already over the “HelloWorld” stage and is addressing the needs of a real world application

That's it for now. I hope I will be able to dive into code quick and painless, so I can see more than a nice facade:)

Ondina
Pages: [1]