To start with, I think that it is not good practice to set or update a component's instance variables by means of arbitrary methods as you have done. Use a 'setter' method to set instance variables. That way, if you get an empty string during debugging, you will know the setter method had not been called. You should also "var" your methods' variables. However, the issue you report is caused by something else.
ColdFusion stores methods as variables, too. In my opinion, when you give the same name to a property and to a method, you place ColdFusion in an ambiguous situation. So change the name of the method in the path.to.base component from 'ID' to 'getID'.
Previous to what I've posted up here, I was using more purist getter/setter methodologies. There were pros and cons to each side, and though many purists don't budge an ounce in their views, I saw a lot of value in writing code like:
<!--- Get the ID. --->
<cfset myID = objectName.ID() />
<!--- Set the ID. --->
<cfset objectName.setProperty( 'ID', 12345 ) />
There was a lot of readability to this method, even though it was not as traditional as code like:
<cfset myID = objectName.getID() />
<cfset objectName.setID( '12345' ) />
The former really allowed for the removal of a lot of code, since I could remove all getProperty() getters (since it used onMissingMethod() when non-existing methods like obj.ID() are called, as well as removing a lot of setter methods, since 1 global setProperty() method could, again, be used to set properties across the board.
I understand there is pro and con to this, it breaks encapsulation, does not allow finite access control, etc. But I've been mulling over whether I want to be an OOP purist vs. realist.
1 person found this helpful
Here, as in every other profession, rules are meant to be broken! The key issue here is not whether you use getters and setters. It is that ColdFusion may be confusing the name 'ID' of the function with that of the property. I think that the problem you have encountered will be solved if you change the name of the function to something else. That is, to anything other than 'ID', not necessarily to 'getID'.
Actually makes a lot of sense. I mean, heck, I'm not not following the non-purist methodologies to be considered a pain in the butt n all but it does come with its own side of cons as well as pros. The fact that I use the onMissingMethod() and omit the getProperty() might be the reason why we don't see the reflection, however the dump of that component's variables scope shows that they are at least being updated accordingly.
Good muse, mi amigo. Appreciate it.