In real OOP languages you are forced to create an object via one of it's constructors. This forces you to provide all the necessary parameters to initialise your object instance.
The problem as I understand it is that you can create an object without initialising it in CF. This is like having a no-argument constructor in every class by default. I understand BlueDragon has a <cfconstructor> for CFC's but I've not looked at it.
 
Barny
----- Original Message -----
Sent: Tuesday, March 16, 2004 3:57 PM
Subject: RE: [CFCDev] RFC, CFC Best Practices

I was just thinking about that last night...
 
My plan was to add a check in each method, but, like you have said, I don't really want to add all that code.
 
How is this done in a real OOP language?  Do those languages have the constructs to better allow this or do you still have to add code in each method?
 
While we are at it and can get some good suggestions, what would be the appropriate reponse in each method?  Throw an error such as: "Instance not inited"?
 

From: Raymond Camden [mailto:[EMAIL PROTECTED]
Sent: Tuesday, March 16, 2004 9:38 AM
To: [EMAIL PROTECTED]
Subject: RE: [CFCDev] RFC, CFC Best Practices

Speaking of init - how do folks handle cases where they want to force an init w/ arguments? For example, maybe the CFC needs a datasource name in order to work correctly. I don't want to add checks to all my methods to make sure Init() was called. I _could_ use defaults but that wont apply in all cases.
 

=======================================================================
Raymond Camden, ColdFusion Jedi Master for Mindseye, Inc
Member of Team Macromedia

Email    : [EMAIL PROTECTED]
Blog     : www.camdenfamily.com/morpheus/blog
Yahoo IM : morpheus

"My ally is the Force, and a powerful ally it is." - Yoda

 


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Dawson, Michael
Sent: Tuesday, March 16, 2004 9:24 AM
To: [EMAIL PROTECTED]
Subject: RE: [CFCDev] RFC, CFC Best Practices

I would rather use a specific Init() method rather than rely on a behavior of the CFC.  I previously used the psuedo-constructor area, but with an uneasy feeling that MACR may change it and, in turn, break my code.
 
By specifying Init(), MACR is less-likely to break my code w/o affecting all other users as well.
 
A compromise would be to coding an Init() method, but also invoking that method in the psuedo-constructor area...

Reply via email to