The Dopefly Tech Blog

« The Dopefly Tech Blog Main page

Should CFML have first class properties?

posted under category: ColdFusion on December 3, 2009 by Nathan

C# was the first mainstream programming language, to my knowledge, that had full language support for properties, phasing out getters and setters (accessors and mutators). The idea is simple. Here is a property:

public String Name;

This gives your object a public property that can be read and written. The process is similar in Java and ColdFusion, but when the time comes to add functionality to Name, such as calculate the value on the fly, or invalidate a cache when the value changes like I do in Pagination.cfc, you have to graduate this into a getter and setter. In C#, you just have to change the property, keeping your object's interface safe:

private String _Name;
public String Name {
get {
// some code
return _Name;
set {
// some code
_Name = value;

Properties inherit simplicity when compared to the standard getter and setter. They give you less typing and fewer interface changes.

It can actually go deeper than that, with property change event listeners and more.

In the Java world, this properties debate has raged for years, and there are opponents and proponents, both shouting angry words at the other side (they call it the JCP). I think it will never happen, Java is a mountain: basically immobile, without an act of God. CFML is a rocket, in comparison. Allaire / Macromedia / Adobe have pushed CFML hard, keeping it current. Much more so with the latest release and the CFML Scripting enhancements.

Adobe ColdFusion 9, which came out a few months ago, blessed us with near magical getter and setter generation, but I wonder if that is not enough. With this feature in place, is it now too late to move the language toward properties? I suppose this becomes a question for (or your potential answers for) the CFML Advisory Committee: how could it be implemented in CFML, the ColdFusion way?

Nathan is a software developer at The Boeing Company in Charleston, SC. He is essentially a big programming nerd. Really, you could say that makes him a nerd among nerds. Aside from making software for the web, he plays with tech toys and likes to think about programming's big picture while speaking at conferences and generally impressing people with massive nerdiness and straight-faced sarcastic humor. Nathan got his programming start writing batch files in DOS. It should go without saying, but these thought and opinions have nothing to do with Boeing in any way.
This blog is also available as an RSS 2.0 feed. Click your heels together and click here to contact Nathan.