Jesse,

In Cairngorm, it's actually our future intention that commands are
stateless; that they are created for each invocation of the command,
rather than once on startup.  However, there are side-effects that can
occur as you move from one implementation to another (they shouldn't
occur, but we take compatibility very seriously).

This would be more inline with the original J2EE microarchitecture that
preceeded Cairngorm (!) and used the same design patterns, where
Commands were created dynamically and on-the-fly.

Expect a future 2.0 version of Cairngorm to have this stateless (where
the invocation of a command is a new command each time, and can
therefore carry no state between invocations in different contexts)
implementation.   We've been wanting to release this since Cairngorm
0.99, but were just aware of too many people inadvertantly depending
upon "statefulness" between invocations.

I believe that if State should be maintained between invocations, it can
be maintained on the ModelLocator.

Best wishes,

Steven
PS.  Alex Uhlmann is probably running happy laps around the office
reading this.

--
Steven Webster
Practice Director (Rich Internet Applications)
Adobe Consulting
Westpoint, 4 Redheughs Rigg, South Gyle, Edinburgh, EH12 9DQ, UK
p: +44 (0) 131 338 6108
m: +44 (0) 7917 428 947 
[EMAIL PROTECTED] 

 

> -----Original Message-----
> From: flexcoders@yahoogroups.com 
> [mailto:[EMAIL PROTECTED] On Behalf Of Tim Hoff
> Sent: 17 April 2006 18:24
> To: flexcoders@yahoogroups.com
> Subject: [flexcoders] Re: Cairngorm2 Commands and Singletons
> 
> That's what I thought Jester.  So the problem is not with the 
> commands but rather with the delegates.  The samples provided 
> similar code to this:
> 
>    var delegate : GetAuthorsDelegate = new GetAuthorsDelegate();
> 
> I'll make these singletons and see if that clears up the problem.
> 
> Thanks,
> 
> - TH
> 
> 
> --- In flexcoders@yahoogroups.com, "JesterXL" <[EMAIL PROTECTED]> wrote:
> >
> > Cairngorm at start up creates a single instance of a command class
> at start 
> > up.
> > 
> > ARP, another framework like Cairngorm, creates an instance of a
> command when 
> > it's called.
> > 
> > Multiple calls to a Cairngorm command via EventBroacaster use the
> same 
> > Command instance.
> > 
> > Multiple calls to an ARP command via EventBroacaster use a new
> Command 
> > instance.
> > 
> > While I've been told Commands should be stateless, I disagree.  
> Since you 
> > can't block in Flash Player and everything is asyncronous, I think
> Commands 
> > should have some form of state, even if this state is internal,
> and is 
> > merely in the form of callback functions that it only uses for
> itself (aka 
> > private).
> > 
> > That said, Cairngorm's low-level design clearly believes and
> encourages 
> > stateless Commands since only 1 instance of a Command class every
> exists.
> > 
> > Cairngorm keeps a reference to the Command class instances, so
> they don't 
> > really ever go out of scope because they are kept internally in
> the commands 
> > array.
> > 
> > I know that's not a solution, just information, but figured
> important 
> > nonetheless.
> > 
> > ----- Original Message -----
> > From: "Tim Hoff" <[EMAIL PROTECTED]>
> > To: <flexcoders@yahoogroups.com>
> > Sent: Monday, April 17, 2006 12:46 PM
> > Subject: [flexcoders] Cairngorm2 Commands and Singletons
> > 
> > 
> > Apparently, there has been much discussion concerning 
> singletons here 
> > already, but the search feature of this site doesn't seem to ever 
> > return complete results.  Coming from a .NET background, 
> I've had to 
> > change a lot my thinking in regards to objects. This is a 
> good thing.  
> > However, in .NET (VB.NET, C#.NET Java.NET) when an object is 
> > instantiated, let's say a class in this case, as soon as the object 
> > goes out of scope, it is automatically disposed of by
> the
> > garbageCollector.  This doesn't seem to be the case in AS3.  I've 
> > patterned an application on the Cairngorm samples that have been 
> > provided so far.  The samples are great and I really 
> appreciate them, 
> > but none of them make multiple calls to the back-end.  
> Using the code 
> > provided, if I execute multiple search commands (let's say 
> > getAuthors), each one of the command instances, along with the 
> > associated event listeners and objects, still exist after the
> result
> > or fault is returned.  Thus, when an error is displayed
> > like: "Sorry, no authors found.", since all of the 
> commands/delegates 
> > are still listening to the data service, a separate alert 
> box appears 
> > for each instance of the command.  Three calls, three alert boxes.
> > 
> > I'm not sure if I should make the commands and delegates
> singletons,
> > or manually dispose (delete _oSingleton) of the instances.  
> Since the 
> > application is Cairngorm based, I don't want to stray too far from 
> > best practices.  I was just wondering if anyone else had 
> experienced 
> > this problem and if there were some links or advice
> that
> > could be offered?  I also want to say that I think that the 
> Adobe team 
> > is doing a great job.  I can't wait for the release of Flex2.
> > It's going to turn a lot of heads.
> > 
> > Many thanks,
> > Tim Hoff
> > 
> > P.S.  It would be nice to have something like the following:
> > 
> > public singleton class myClass {}
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > --
> > Flexcoders Mailing List
> > FAQ: 
> http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> > Search Archives: http://www.mail-archive.com/flexcoders%
> 40yahoogroups.com
> > Yahoo! Groups Links
> >
> 
> 
> 
> 
> 
> 
> 
> --
> Flexcoders Mailing List
> FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> Search Archives: 
> http://www.mail-archive.com/flexcoders%40yahoogroups.com
> Yahoo! Groups Links
> 
> 
> 
>  
> 
> 
> 


--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to