This entry comes from the "better late than never" department.

For years I have been coding with ColdFusion components. And for years I have resisted the calls to use an init() function, mainly because none of my components to date had ever been initializing anything. I would either pass in arguments to functions as needed, or I would use the application scope for things like datasources or file directories. It was one of those "What good is it?" type of deals.

Well, for the first time I am working on a project that I might decide to release out to the public if it goes as I hope. It's an error-handling project, based on methods I have been using for over six years now. So my thoughts have turned to how to make this portable, not just to my sites where I have a very consistent approach to coding but to others who probably code completely differently from me. I wanted to keep databases out of this project (what good is an error handler storing errors in a database if the database is the problem, and also as another way to make it portable) so I am using an XML file for configuration information. Where best to read this in? An init() function! Now I have my first need of it and am using it.

In the course of my research on best practices for using it, I ran across the Object Oriented ColdFusion site and their writeup on using init() had this in it:

"When you first create a new component the init() function may have no apparent need, but as your application grows you may find that your component changes and you need to initialise your objects into a particular state."

That struck a chord in me, and so from this point forward I am embracing the standards of using an init() function in every component I write, even if at the time it does nothing. I may be slow to change, but I'm not completely stubborn. Some of the time, at least.