Sam Farmer

Growing up I never imagined I would play bass guitar for the Dave Matthews Band. And indeed it never happened.

But I have become passionate about making software.

Would you like to code this way?

September 27, 2007

Recent blog postings by Jason Delmore, the CFInsider, on ideas for ColdFusion 9 got me thinking about how I code. Taking a look at the beautiful/hacky/cool code I produce I noticed a few things where the language could really help me. The first is I have a large chunks of cfsets and secondly control tags (classified as Flow-control tags on Livedocs) could be simplified.

I find that big chunks of cfset's really clutter up the page and take my eye away from the important part -- what is actually being set. What if there existed a hybrid between cfset and cfscript that allowed the following to happen:

<cfset variables.firstname = "Sam";  variables.lastname = "Farmer";  variables.myObject = createObject("component","weather").init();  variables.temp = variables.myObject.getTemperature("20001");>

(And, yes, I know I could use cfscript but in general I don't like using it as its not feature complete and when I did used to use it in places like above I found it hard to know when to and when not to. Just setting one variable hardly seems worth it, two variables? borderline, then there's the case where I already have two cfsets and now I want to add two more and its "is it worth converting to cfscript?", etc.)

I like the tag and attribute concept (and really how could you like ColdFusion and not?) but in examining my code I kept coming back to the idea that control tags should work differently. This would make them easier to find, quicker to code and more similar to other languages.

For instance looping over an array could use the same syntax as in Javascript:

<cfset variables.arDays = ["Monday","Tuesday","Wednesday","Thursday","Friday"]>  <cfloop variables.i in variables.arDays>  <cfoutput>#variables.i#</cfoutput> </cfloop>

Structures, files and lists could be looped over in the same way. A query could be looped over by just saying cfloop getQueryName. I think these concepts could be expanded to other tags (cfswitch immeadiately comes to mind) and would make the switch to CF easier for many folks.

Would you like the code in theses ways? I'm mainly thinking out loud so I'd love to hear your thoughts.


No Comments

Some comments have been lost over the years due to moving hosts.

More


More blog entries that I have written.

Code coloring by PRISM.