What is the problem with using CFC this. variables? Are they not thread safe? Where does MM document they are not thread safe? Is there example code that would cause a thread failure using this. variables?
Yes, the getter/setter proponents seem to think a function call is better CF and it is effective encapsulating. But for the code in me I cannot figure out why. It just seems to me that getter/setter for individual instance variables is a lot of extra runtime memory allocations, that in itself can cause memory leaks or thread failures. Functions in a CFC have namespaces just like this. scope variables. By CF definition, all function names are CF variable namespaces. The difference between public instance variables and private instance variables, besides scoping rules, is when memory allocation occurs, loadtime or runtime. this. scope allocations happen at loadtime. Private variable allocation happen at runtime. Function names are public variables, the function internal variables are private. The CFC this. variables are an extremely powerful feature in a CFC. If the application uses CFC this scope, CFC variable namespace act as a pass-by-name reference. The getter/setter functions most often use pass-by-value for individual instance variables. Whereas by using the CFC this. scope and simple expression statements, variable assignments conserve memory allocations because the CFC variable space is a CF data structure. (Note. Memory allocation is a runtime compiler function not memory use nor memory availability.) The good old equal sign in a statement is really a built-in function that is an elegant "setter". By adding user getter/setter functions individual instance variables complicates CFC data structure. The difference between an equal expression and a function call is when memory allocation occurs. Equal-expression memory space happens at loadtime and for the most part is fixed for that application execution. Getter/setter functions force dynamic memory allocation at runtime which causes changes in the application memory stack. It is these changes in memory stacks that expose risks for thread failures. Those of you who read this and who are encapsulation fans will not agree with me recommending the use of this. scope. So while I am on the topic, encapsulation means discrimination by design. It means declaring object definition and discarding all other possibilities. getter and setters is not encapsulation, it just one of many means to effect discrimination. Declaring a CFC defined with this scope instance variable is a means of encapsulation by structure not by value. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Special thanks to the CF Community Suite Silver Sponsor - RUWebby http://www.ruwebby.com Message: http://www.houseoffusion.com/lists.cfm/link=i:4:188786 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54