Now, in CF, how do we maintain a piece of state that has to be shared by all
instances of a CFC?  Maybe something like this:

1. Define a new CFC to encapsulate that state and provide methods for
manipulating it.
2. Instantiate that CFC as a singleton
3. Inject the singleton into each new instance of the dependent class.

Because #3 requires that we have control of instantiation of all new
instances, we then need to:

4. Create a factory CFC to do the instantiation and injection.  Could the be
same CFC as in #1.  Or could use a DI framework.

Where the piece of state in question is some fundamental property of all the
instances, what we've just done is create a "class object" - an object which
represents a class of objects, i.e. every instance of a particular CFC.
It's methods aren't static, in that they are tied to an instance, but they
can act as class methods.

Jaime Metcher




You are subscribed to cfcdev. To unsubscribe, please follow the instructions at 
http://www.cfczone.org/listserv.cfm

CFCDev is supported by:
Katapult Media, Inc.
We are cool code geeks looking for fun projects to rock!
www.katapultmedia.com

An archive of the CFCDev list is available at 
www.mail-archive.com/[email protected]

Reply via email to