It is supposition, in fact, it's my original question. We've had a few
discussions on this list about var scoping, and I was still unclear on how
CFC would behave if you didn't var scope the return values from tags like
cfquery, cfhttp, cfftp, cfcatch etc.
I double-checked with the product team - here's their answer:
"The cfcatch structure is really just the java exception, which gets wrapped by one of our ExceptionScope objects that makes it appear more struct like.� The ExceptionScope gets generated on the fly when we try and access the exception like a structure, and we don't cache them or anything."
Note that cfquery is the odd man out in your example since you can (and should) var-declare the variable into which you want the result placed. All the others have a fixed struct-like result which is created on the fly as needed.
Based on what I've gathered from
conversations on this list, if you don't var scope those variables, they
will (by default) exist in the Variables scope.
True for cfquery because it places the result in a variable of your choosing.
If it's in the Variables scope, doesn't that mean that it's shared among all requests using that instance of the CFC?
Correct - which is why var-declarations are so important.
I love CFCs and I'll never go back. I'm just not convinced that it's worth
it to try to use CFCs to implement typical OOP design patterns.
It is, believe me :)
The lack of interfaces in CF mean that you cannot slavishly map Java-coded patterns to CF-coded patterns but the design patterns can certainly be applied to CF and are worthwhile. The hard part of doing this is that most of the literature uses Java, C++ or Smalltalk to illustrate the patterns rather than CF. Brendan O'Hara has done a sterling job of providing CF versions of several design patterns:
http://www.sys-con.com/coldfusion/article.cfm?id=577
There are a
few instances where using OOP concepts makes things cleaner, but in most
cases I'm finding that the implementation becomes convoluted.
It takes time for OO design to become natural - and early attempts at OO design often create convoluted results. Over time, things improve.
For all you macromedia guys reading this list.. sorry for the "slapped
together" comment. I guess I was in a bit of a mood that day. CFCs are
awesome and I agree that they're the single best improvement in ColdFusion
since custom tags.
Cool! :)
Sean A Corfield -- http://www.corfield.org/blog/
"If you're not annoying somebody, you're not really alive." -- Margaret Atwood
---------------------------------------------------------- You are subscribed to cfcdev. To unsubscribe, send an email to [EMAIL PROTECTED] with the word 'unsubscribe cfcdev' in the message of the email.
CFCDev is run by CFCZone (www.cfczone.org) and supported by Mindtool, Corporation (www.mindtool.com).
An archive of the CFCDev list is available at www.mail-archive.com/[EMAIL PROTECTED]
