Andrew,

Sure... from what I've seen of the singleton pattern in other languages, 
the implementation we use (I didn't build it) is a lot easier.

This is essentially how it works:

1. Created a central method called "getSingleton" that manages the 
creation and retrieval of singletons.

        any getSingleton(string componentPath)

2. The getSingleton method checks to see if a key matching the 
componentPath exists within a struct stored in application scope.

        a) If the key doesn't exist, then a new key is inserted into the 
struct, and its value is the instantiated component (with appropriate 
locking).

        b) The persistent instance of the component is returned.


That is essentially how it works.

Darryl 


[EMAIL PROTECTED] wrote on 01/03/2005 09:00:51 AM:

> Daryl,
> 
> I have been trying to understand how the singleton pattern could be 
applied
> to CF, would you be able to elaborate more on this or give an example of 
how
> its applied. Not just for me, but for others out there that would like 
to
> know as well.
> 
> I understand how it works in C#, Java, but for some reason can't get my 
head
> around how it could be applied to CF, maybe its just me missing 
something.
> 
> 
> Regards
> Andrew Scott
> Technical Consultant
> 
> NuSphere Pty Ltd
> Level 2/33 Bank Street
> South Melbourne, Victoria, 3205
> 
> Phone: 03 9686 0485  -  Fax: 03 9699 7976
> 
> 
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of Darryl 
Lyons
> Sent: Tuesday, 1 March 2005 9:52 AM
> To: CFAussie Mailing List
> Subject: [cfaussie] Re: CFCs calling CFCs
> 
> Barry,
> 
> Singletons are cool - it is amazing what a difference application or 
session
> scoped singletons make to performance, especially in models where 
methods
> and components are reused a lot.
> 
> Darryl Lyons
> 
> [EMAIL PROTECTED] wrote on 01/03/2005 08:40:40 
AM:
> 
> > 
> > Kay,
> > 
> > we do something similar to Darryl & co (passing in a reference to the 
> > helper object in the init of the main object, and using singletons too 

> > for the same reason) but I'm not sure whether Fusebox4 could squeeze 
> > in this idea..
> > 
> > the thinking was, thanx to complex "objects" (ie CFC's) being passed 
> > byRef,  what looks like decorating the main CFC with extra 
> > functionality is actually providing a pointer to the "helper" CFC
> > 
> > more here:
> > http://www.mail-archive.com/[email protected]/msg06886.html
> > 
> > 
> > just a thought
> > barry.b
> > 
> 
> 
> 
> To unsubscribe from this email please forward this email to
> [EMAIL PROTECTED] 
> 
> This email message is confidential and may be privileged. If you are not 
the
> intended recipient please forward the email to 
[EMAIL PROTECTED]
> and delete the original.
> 
> ABN AMRO Morgans Limited and its associates hold or may hold securities 
in
> the companies/trusts mentioned herein.
> Any general advice included in this email has been prepared without 
taking
> into account your objectives, financial situation or needs.
> Before acting on the advice, you should consider its appropriateness or
> discuss with one of our investment advisors.
> 
> ABN AMRO Morgans Limited (ABN 49 010 669 726 AFSL 235410) A Participant 
of
> ASX Group.
> A principal member of the Financial Planning Association.
> 
> 
> ---
> You are currently subscribed to cfaussie as: [EMAIL PROTECTED] To 
unsubscribe
> send a blank email to [EMAIL PROTECTED]
> Aussie Macromedia Developers: http://lists.daemon.com.au/
> 
> 
> 
> 
> ---
> You are currently subscribed to cfaussie as: 
[EMAIL PROTECTED]
> To unsubscribe send a blank email to 
[EMAIL PROTECTED]
> Aussie Macromedia Developers: http://lists.daemon.com.au/



To unsubscribe from this email please forward this email to [EMAIL PROTECTED] 

This email message is confidential and may be privileged. If you are not the 
intended recipient
please forward the email to [EMAIL PROTECTED] and delete the original.
 
ABN AMRO Morgans Limited and its associates hold or may hold securities in the 
companies/trusts mentioned herein.
Any general advice included in this email has been prepared without taking into 
account your objectives, financial situation or needs.
Before acting on the advice, you should consider its appropriateness or discuss 
with one of our investment advisors.

ABN AMRO Morgans Limited (ABN 49 010 669 726 AFSL 235410) A Participant of ASX 
Group.
A principal member of the Financial Planning Association.


---
You are currently subscribed to cfaussie as: [email protected]
To unsubscribe send a blank email to [EMAIL PROTECTED]
Aussie Macromedia Developers: http://lists.daemon.com.au/

Reply via email to