ColdFusion Contest - Final Entries

So, this contest has taken way longer than I thought it would, but that just speaks to how many responses I got, which I think is a good thing. If you haven't looked at the previous entries, I suggest that you do so. I'm going to quickly link to and point out the final two entries, and tonight I will pick a winner. (Along with releasing Starfish Version 0 hopefully.)

The first entry works pretty well, and has an interesting feature. If it catches you fibbing about your number, it will call you a lier. Nice. One thing I noticed about this sample is an odd use of "this" in the code. Here is a sample that I've mashed together:

<cfset request.this.title = "Guess The Number"> <cfset session.this.guessrange = 100>

I've pinged the writer to see why he uses scope.this.var and hopefully he will respond. That being said, I do have a problem with this. ColdFusion will let you automatically create a structure without using structNew(). Consider this code block:

<cfset z.y = "foo"> <cfdump var="#z#">

This works, but is dangerous. If for some reason you added <cfset z = 1> before the cfset above, the code will not work and will throw this error: You have attempted to dereference a scalar variable of type class java.lang.String as a structure with members. Simply adding the structNew() fixes the problem:

<cfset z = 1> <cfset z = structNew()> <cfset z.y = "foo"> <cfdump var="#z#">

So in general, I'd probably always recommend against relying on ColdFusion to automatically create a structure for you as the author did above.

The last entry gets bonus points for providing both a CFC version as well as a basic version. I didn't have much to say about this one so for now I'm just providing the links so folks can play with it.

So that's it! Tonight I will announce a winner (which I'm sure no one will disagree with, ahem) so check back again.

Raymond Camden's Picture

About Raymond Camden

Raymond is a developer advocate. He focuses on JavaScript, serverless and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support. You can even buy me a coffee!

Lafayette, LA