Using StructFind for fun and profit

There is a very weird debate going on in the CF-Aussie list about the merits of the ColdFusion function structFind(). StructFind( struct, key ), is an aptly-named native function that fetches the value of the specified key, in the specified struct. If, for some reason, the key does not exist, it throws an error. (The docs are wrong)

Why would you ever need this function? One use case would be returning the value a key in a structure that is the result of a function evaluation. Take this example:


Pablo Vos Presents Ten facts why Coldfusion beats PHP and ASP

Someone just forwarded an article from Pablo Vos, "10 facts why ColdFusion is better than PHP or ASP". The 10 facts are are compelling reasons why IT managers and executives should prefer ColdFusion over PHP or ASP.

In my experience, ColdFusion makes the most sense as an enterprise web application development language. Compatibilities with other languages, integrated libraries and high levels of language functionality all make for the fastest application delivery platform available.

Clients tell me of the extra effort in Offshoring complex projects but feel they have no choice due to the manpower needed to keep IT systems current and competitive. I consistently work with them to show how utilizing ColdFusion will accomplish their goals and reduce needed IT FTEs.

We are entering a new dawn of ColdFusion. Increasing amounts of organizations understand how ColdFusion can tie into disparate systems and quickly offer feature-rich applications requiring minimal maintenance manpower.

After all, success in business is in spending less and accomplishing more than your competitors, isn't it?

ColdFusion Developers - Spot the Mistake

Take a look at this code:

view plain print about
1<cffunction name="getFilterString" output="false" access="public" returntype="string" hint="I return the search filter list">
2 <cfargument name="avoid" type="string" default="" />
3 <cfset var x = "" />
4 <cfset var dynHasFunct = "" />
5 <cfset var dynGetFunc = "" />
6 <cfset var rtnVal = "" />
8 <cfloop collection="#variables.instance#" item="x">
9 <cfset dynHasFunc = variables["has#x#"] />
10 <cfset dynGetFunc = variables["get#x#"] />
11 <cfif NOT listFind( arguments.avoid, x) AND dynHasFunc() >
12 <cfset listAppend( rtnVal, "#x#=#dynGetFunc()#", "&") />
13 </cfif>
14 </cfloop>
15 <cfreturn rtnVal />
16 </cffunction>

I just spent 15 minutes tracing all this code out trying to find out why nothing was returned. The intent of the code is to build a string containing values present in the object. So if a user searches by Category, UserID etc, the search string is maintained.

Warning, the error is simpler than you might think. Don't over think it.

Rewriting my blog in an emerging rich web technologies such as AJAX, Flex or Silverlight

Effective immediately, I will be rewriting this blog software in an emerging rich web technologies such as AJAX, Flex or Silverlight. Now if I could just figure out how to query a database using an emerging rich web technologies such as AJAX, Flex or Silverlight......

If you get the reference, give yourself 10 points.

If you do not, here is a picture of a funny looking cat.

Any comments containing the name or URL of a certain 'publishing' (read: Microsoft Shill Corporation) company, will be deleted out of hand.

This needs to be said once in a while. For the good of the children, please turn off Report Execution Times in your CF Administrator.

If you are using a framework written in CFCs, or a library of CFCs, or ANYTHING to do with CFCs, Report Execution Times does not return correct information. As a matter of fact, the Report Execution Times feature will bog down your Application, Framework or Page.

So turn it off. Seriously. For the good of the children.

Nice post on The Model-Glue Event Lifecycle

ModelGlue Users and especially my MG series users, have a read on Doug Boude's Blog about the The Model-Glue Event Lifecycle.

Doug has a lot of other interesting Model Glue related content as well. Here are three of my favourites:

Model Glue Views Demystified

Basic Event Security in ModelGlue

Dynamic Data Stores a ModelGlue Case Study

Some thoughts on OO and the Industrial Revolution

Object Oriented programming has come up again as a topic du jour and is quite possibly one of the more divisive topics in the ColdFusion world, apart from Framework religion of course.

Some may view OO as a smarter way to code. Some may view OO as a pain inflicted upon them by a Development Manager. Some may view OO as simply another elitist autocategorization. "Hey man, I am more 1337 than you. Even nOOb has OO in it, har har har. I have felt all of the above at one time or another.


So you want to use Transfer ORM in your ModelGlue:Unity application (Part 1)

Previously, we connected Transfer ORM into our ContactOMatic application. Now, we will use it to get some things done! The completed files for this exercise are included at the bottom of the post, just click on the 'Download' link.

Using Transfer with MG:U is quite different than hand coding all the data access instructions so I separated out the new Transfer enabled code from the old hand coded bits to help compare similar operations between the two styles. This means the ContactOMatic is not an example of Architectural Purity! Shock! Horror! Gasp!

To make the separation, I added another ModelGlue configuration file, named ContactAction.xml, to the main ModelGlue.xml file through the use of the include tag as follows:


Download Download

Thanks Adobe onAir BusTour

This past Saturday evening, the Adobe onAir Bus Tour breezed into Raleigh/Durham for a three hour stop. Mike Chambers and Kevin Hoyt gave presentations on AIR, the technology formerly known as Apollo, and the rest of the onAIR Bus Tour team took questions.

Overall, I was left with the impression that jumping from Web Application Development to AIR Application Development can be very easy and the learning curve is small. By leveraging skills I already possess, HTML, Javascript, Ajax Frameworks, and Flex/ActionScript, I can create relevant cross-platform applications with all the power and reach of Native Desktop applications.


The Evil Side of Maintain Database Connections and Stored Procedure Errors

A word of caution. When working with Stored Procedures in a development environment, do yourself a favor and untick the 'Maintain Database Connections' option.

If a stored procedure call results in an error, Maintaining Database Connections will sometimes cache the error and hand it back to you regardless of how the call is altered. These are very annoying symptoms to debug! In fact, when I first figured this out, I had already spent 4 hours the previous day combing through an Oracle stored procedure for any possible error when I logged in fresh at 8AM to find the process magically working. I felt like I was on Candid Camera. When I dug deeper, I found unticking 'Maintain Database Connections' would allow my SQL Stored Procedure calls to process fresh each time.

So you can pull out your hair if you want to, or you can untick Maintain Database Connections in your development environment.

A note, the Maintain Database Connections setting is under the Advanced Settings for a specific Datasource configuration. As far as I know, you will have to alter every datasource individually.