|
|
01.27.10 How To Improve Your CFSCRIPT By
Sean Corfield One of the new features in Adobe's ColdFusion 9 release that has excited a lot of developers is the broad range of enhancements to CFML's "other" language: CFSCRIPT. In the past, I've been very disparaging about CFSCRIPT and I've gone so far as to say in several public – and private – forums that I felt CFSCRIPT should be deprecated and no further effort spent on it. It was always a bit half-baked with weird restrictions and lots of important features missing. It was annoying to use, because you often had to switch back to CFML's tags to get things done. With increased use of CFCs, the restrictions in CFSCRIPT made it even more painful to use because you could not specify function arguments easily in CFSCRIPT – no types, no defaults – and you couldn't express a function's access or return type. When ColdFusion 8 appeared, with so many small improvements in CFSCRIPT, making it a bit more like JavaScript, those restrictions on function declarations were even more frustrating because other parts of CFSCRIPT had finally become almost pleasant to use. I was working with CF8 a lot and found myself using CFSCRIPT more and more because of the more JavaScript-like operators. Consequently, I found myself writing this sort of code a lot: ![]() Ugh! If you're a ColdBox user, you'll be familiar with this because it's Luis's style for writing event handlers. I don't know about you but the more I worked with CFSCRIPT, the more this style of function declaration started to annoy me!
So, I started to simply use CFSCRIPT for public functions (and sometimes private ones) and just accepting a return type of "any" (the default) and arguments with "any" type (again, the default). Sometimes I even went as far as using arrayLen(arguments) to figure out whether optional arguments were passed in. Sad, but true. Enter Railo which allowed argument types and defaults in CFSCRIPT (I don't know quite when Railo added support for that but it was quite a long time ago). I still couldn't specify function return types and access but I could at least specify optional arguments properly:
Continue reading this article. About the Author: Sean is currently Chief Technology Officer for Railo Technologies US. He has worked in IT for over twenty five years, starting out writing database systems and compilers then moving into mobile telecoms and finally into web development in 1997. Along the way, he worked on the ISO and ANSI C++ Standards committees for eight years and is a staunch advocate of software standards and best practice. Sean has championed and contributed to a number of CFML frameworks and was lead developer on Fusebox for two years. |
|
|
|
|
-- coldfusionpronews is an iEntry, Inc. publication -- iEntry, Inc. 2549 Richmond Rd. Lexington KY, 40509 2010 iEntry, Inc. All Rights Reserved Privacy Policy Legal archives | advertising info | news headlines | free newsletters | comments/feedback | submit article |