for (i = 1; i <= n; ++i) { ... }
is just so much easier to read than the alternatives.
I think part of my shift to <cfscript> is driven by the fact that I'm also doing a lot more JavaScript these days as well as increasingly using ActionScript so it's easier to jump from one code base to another if they're all script-based.
I'm even writing entire components in <cfscript>. Did you know you can omit <cfcomponent> inside a CFC? Yes, you can just write a CFC like this:
<cfscript>
function init() { return this; }
function getFoo() { return variables.foo; }
function setFoo(foo) { variables.foo = foo; }
</cfscript>
The equivalent default tag attributes are returntype="any" access="public" on the functions and type="any" required="true" on the arguments. That's fine for a lot of methods but it gets a bit frustrating if you want a private method or you actually want to specify return types or argument types or defaults.
I've also started using type="component" instead of type="any" for my "duck typing" when I know I'm really passing a CFC (there are still many times when I'm passing either a CFC or a primary key - and then using isObject() to see whether I need to load the object from the PK). Writing type="WEB-INF.cftags.component" was just far too much work so I'm glad Adobe added this shorthand type name!
Also, as I mentioned earlier, per-application mappings have been a huge help already on shared hosting.
What little ColdFusion 8 features are you enjoying using on your newly upgraded production systems?function init() { return this; }
function getFoo() { return variables.foo; }
function setFoo(foo) { variables.foo = foo; }
</cfscript>

8 responses so far ↓
1 Dale Fraser // Oct 28, 2007 at 2:43 PM
I'd love to be able to write CFC's in script, but it's hard to have coding standards around it where depending on the function you are writing it may or may not work.
Do you think they will improve the ability to declare all function types in CF9 using script.
2 Thomas Messier // Oct 28, 2007 at 5:28 PM
3 tony petruzzi // Oct 28, 2007 at 8:44 PM
god i love having built in image manipulation now and not having to roll my own java or depend on other's.
array and struct syntax
having been doing quite of bit of javascript myself, it's just so much cleaner using [] and {} then arraynew and structnew. now only if we could nest the syntax.
4 Sean Corfield // Oct 28, 2007 at 9:15 PM
5 Tom Barr // Oct 28, 2007 at 10:45 PM
The nice thing is that for a few lines of code I can get an asynchronous data grid that can sort and get another sub-set of data without browser reload.
6 Ken Dunnington // Oct 29, 2007 at 5:50 AM
7 Thomas Messier // Oct 29, 2007 at 6:43 AM
8 Adrian Lynch // Nov 2, 2007 at 2:44 PM
I never used to use CF mappings but now it's nice and easy I do.
Oh and REMatch() saves some time.
Adrian
Leave a Comment