ColdFusion 10 and Implicit constructor problem gotcha
Tags: Coldfusion, ColdFusion 10
I had a very quick play with this while I had some time on my holiday, and I can see that although the concept was something that can be used, its implementation is left for future problems.
When using the implicit constructor, you have to have accessors set to true or it has to be an entity. That enables the fact that you can use the constructor implicitly, but it will also override the standard constructor.
What that means is that with all the applications that are currently using a constructor to setup things, or pass in other things will run into further problems.
So lets look at an example that fails.
/* Setup The Controller. */
setController(arguments.controller);
}
This is a bean that I am passing in another component that will provide more functionality, this is not a great example, but does give meaning to this problem that others could face down the track.
Now I know people could argue that I can still use the implicit constructor to do this still, but then this variable then becomes open, and is not private to the component like I need it to be. Because if you turn the setter and getter to false, then the implicit variables are never set.
ColdFusion 10 is going to create some problems here with people trying to use the implicit constructor with scenarios like this, and it will not work the way they think it will.
Now in time people may work around this, and modify there applications in time. But the constructor is there for a reason, and is used for other things than just to populate the component. And it is for that reason that I think that ColdFusion 10 should have adopted something like this.
book = new Book( ).populate(title : "My Book Title", description: "A really cool book");
</cfscript>
I am not sure how others feel about this, but I can foresee many people falling into the trap that think their normal constructor will still also run, and it won't. And although I like the idea of being able to populate the bean / entity / component, I don't think that the way it has been implemented is the best thought out solution.
There are no comments for this entry.



TweetBacks