Inheritance and cfproperty Tags

I have an application that uses value objects. In order to avoid public instance variables we use cfproperty tags to determine instance variables. When you extend the value object the property tags are not inherited.

To circumvent this what I have done is create an array in the variables scope:

variables.objprops

In the value objects init method I grab the properties using

props=getMetaData(this).properties

I then check for the existence of variables['objprops'] and if it doesn't exist create it as an empty array.

I loop through the array (props) and append them to variables['objprops'].

Since a subclass may override a property in the parent class I replace rather than append if a property of the same name exists in the array. Since the init method of the parent class is called first this effectively overrides property in the parent class.

We use the onMissingMethod function to create implicit setters and getters but that is a topic for another post.

Comments
Manu's Gravatar Thanks for sharing !
# Posted By Manu | 5/17/10 1:05 PM
BlogCFC was created by Raymond Camden. This blog is running version 5.9.4.001. Contact Blog Owner