DK
On 8/30/06, Dave Ross <
[EMAIL PROTECTED]> wrote:
If foo is a transient or "value" object (things like User, Department,
Store, Cart, CartItem) then no, ColdSpring generally shouldn't be
involved with their creation. There shouldn't be any references to
ColdSpring in your code (or to the application scope!) which is why
option 1 is so bad.
Often times objects are created in different layers - some controller
layers create objects (Mach-ii's <event-bean/> tag for example).
Sometimes ORM frameworks create objects - usually hand-coded DAOs
create Objects. If they all had to talk to ColdSpring it would be a
serious mess.
If foo has dependencies, it's best to set them manually within whoever
is creating instances of foo. In my experience, value objects like
your "foo" have zero dependencies (the "anemic domain" I know and
love).
-Dave
On 8/30/06, Matt Williams <[EMAIL PROTECTED]> wrote:
> Then probably do option 1:
>
> <cfset myInstance = application.serviceFactory.getBean('foo') />
>
>
> On 8/30/06, Douglas Knudsen <[EMAIL PROTECTED]> wrote:
> > right, if I need only one of foo.cfc inside MyUberCFC. But in this case I
> > may need to create 0 - n instances of foo.cfc inside MyUberCFC.
> >
> > DK
> >
> >
> > On 8/30/06, Matt Williams <[EMAIL PROTECTED]> wrote:
> > >
> > ColdSpring can autowire the beans together.
> > You register the MyUberCFC.cfc in the CS config file also and tell CS
> > to get an instance of foo
> >
> > <bean id="MyUberCFC" class="cfcs.MyUberCFC">
> > <property name="foo">
> > <ref bean="foo">
> > </property>
> > </bean>
> >
> > Then your MyUberCFC needs a setter function...
> > <cffunction name="setFoo" ...>
> > <cfargument name="Foo" ...>
> > <cfset variables.Foo = arguments.Foo >
> > </cffunction>
> >
> > Then any other function in MyUberCFC can access Foo's methods via
> > variables.Foo.doSomething ()
> >
> > On 8/30/06, Douglas Knudsen <[EMAIL PROTECTED]> wrote:
> > > ok you coldspringers! Say I'm using ColdSpring and have it all setup and
> > > running. I have the CFC foo.cfc registerd as a bean in teh coldspring.xml
> > > file. Now I create a new CFC called say MyUberCFC.cfc. Inside this CFC I
> > > need to create a instance of foo.cfc. Is it best practise to use the
> > > coldspring factory here? ie should I use
> > >
> > > <cfset myInstance =
> > > application.serviceFactory.getBean('foo') />
> > >
> > > or just use
> > >
> > > <cfset myInstance = CreateObject('component',' path.to.foo') />
> > >
> > > or maybe I should have a application facade CFC in use?
> > >
> > > --
> > > Douglas Knudsen
> > > http://www.cubicleman.com
> > > this is my signature, like it?
> >
> >
> > --
> >
> > Matt Williams
> > "It's the question that drives us."
> >
> >
> >
> >
> > --
> > Douglas Knudsen
> > http://www.cubicleman.com
> > this is my signature, like it?
>
>
> --
> Matt Williams
> "It's the question that drives us."
>
>
--
Douglas Knudsen
http://www.cubicleman.com
this is my signature, like it?
