Over the last few weeks, I have done a lot of thinking about my pursuit of object oriented understanding. One of the points that I have explored thoroughly is the concept of using ColdFusion components as Data Types. While a data type is container of information, I think there is a subtle difference between a data type and a data container; and, it is this subtle difference that I have been pondering as of late.
A data type holds information; but, more than a simple container, the fact that it is a "data type" denotes a greater meaning to the container as a whole - a data type implies certain truths about the data contained within it. Take a String for instance - a string is a data type that implies a collection of character data. Because of this, you know that you never have to worry that accessing the second index of a string will return an XML object or a BLOB. That's part of what makes a String different from any arbitrary array of information.
So, can this concept of data types be applied to ColdFusion components? Well, certainly it could be - all that you would need to do is put the validation logic in the constructor and setter methods. But, the real question that I have come to ask myself is, should the concept of data types be extended to ColdFusion components?
At a purely philosophical level, I definitely like idea of using ColdFusion components as data types; there's a base comfort in knowing certain truths about an object based on its type alone. But, what I am really struggling to do is find any practical use behind such a constraint. In fact, other than this small comfort, I can really only see this constraint as causing friction rather than relieving it.
And so, I am going to abandon this concept. Not because I don't like it, but because I don't believe that it will make my application development easier. I don't believe that CFCs as data types adds any intrinsic value. And, by not living within this constraint, I open up the door to other efficiencies that will have a beneficial impact on my application development.