Viewing By Entry / Main
October 28, 2007
Now that Scazu is running on ColdFusion 8, I can finally start taking advantage of the new features and kick off some of my old habits. One of the things I've found myself doing - much to my surprise, given past pronouncements on this topic - is using <cfscript> more and more. I hadn't expected the ability to use regular comparison (< <= == != >= >) and boolean (|| && !) operators to have such an impact on my coding style!
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?

Comments

Getting There,

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.


I haven't gotten on CF 8 yet, but I look forward to it if only because of the shorthand notation for arrays and structs. One question about cfscript: can you now do most things in script? Like, is there a cfquery equivalent?


cfimage

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.


@Thomas, no, they have not added the equivalent of cfquery - or cflog or cfthrow or cfdump... but the array / struct shorthand is certainly nice (Tony!).


I really like the combination of CFGRID with HTML/AJAX format and databinding. The built in pagination and sorting are great. I have implemented it in the salary search on my site www.salarymap.com: http://www.salarymap.com/salary-finder.cfm.

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.


cfajaxproxy is great! I use jQuery for all my JS work, and cfajaxproxy makes tapping into my CFCs a snap.


I wasn't aware that you can't next the shorthand array/struct syntax, that's kind of a bummer. When you use javascript a lot you start feeling that this is must-have functionality. Hopefully they'll get that done eventually.


I'll second the love for the new array and structure syntax. I'd love for it to work nested.

I never used to use CF mappings but now it's nice and easy I do.

Oh and REMatch() saves some time.

Adrian


Post Your Comments
Name:
Email Address:
Comments
*** Please note that all comments require moderation so it may be some time before your comment posts to this blog! ***
Remember My Information:
 



Hosting provided by