I don't know if there is *no reason* for it. How about this

public class testing(){

        static fakeobj playing;

        public testing(){
                playing = new fakeobj();
        }

        public setIP(String ip){
                playing.ip = ip;
        }

        public void init(){
                Thread blarg = new Thread(){
                        public void run(){
                                playing.connect();
                        }
                }.start();
        }
}

While you could write all the code in the constructor, I think you would
loose the ability to to create an instance of this and then start it up
later.

Looking at this though I do see your point, but I still like using the init
type functions for certain things.



-----Original Message-----
From: Dave Watts [mailto:dwatts@;figleaf.com]
Sent: Friday, November 01, 2002 3:42 PM
To: CF-Talk
Subject: RE: Understanding Locking In CFMX


> That would be cool except for sometimes the init() function
> needs to be called after some assignments. Consider the
> following example
>
> <cfset server.myVar = createObject("component","foo")/>
> <cfset server.thing = handleToSomething>
> <cfset server.startupip = "192.168.1.11">
> <cfset server.init()/>
>
> if "thing" and "startupip" had resources that the object
> needed, and the init() was called without those being
> assigned, the object could blowup.

There's no reason those properties couldn't be set in the constructor
function. That's how most languages would handle this issue. I wouldn't mind
seeing some sort of actual constructor function added to the CFC
architecture, instead of just using the "soft" constructor which simply
consists of stuff not wrapped within CFFUNCTION tags.

Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/
voice: (202) 797-5496
fax: (202) 797-5444


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Your ad could be here. Monies from ads go to support these lists and provide more 
resources for the community. http://www.fusionauthority.com/ads.cfm

Reply via email to