CFML Developers Evolution Scribble

2009 December 13
tags: Coding · ColdFusion
by Big Mad Kev

Having done an import of my old Gmail account into a single Google Apps account, a few old emails came into my inbox, one of which was from my brother with a link to: PHP programmer's evolution scribble

So it made me think about this in the CFML World, so here it is:

Your First CFQuery

<cfquery name="GetParks" datasource="cfsnippets">
SELECT PARKNAME, REGION, STATE
FROM Parks
WHERE Parkname = "#url.parkname#"
</cfquery>

Your Second CFQuery

<cfset request.dsn = "cfsnippets"/>
<cfquery name="GetParks" datasource="#request.dsn#">
SELECT PARKNAME, REGION, STATE
FROM Parks
WHERE Parkname = "#url.parkname#"
</cfquery>

You then hear about SQL Injection

<cfset request.dsn = "cfsnippets"/>
<cfquery name="GetParks" datasource="#request.dsn#">
SELECT PARKNAME, REGION, STATE
FROM Parks
WHERE Parkname = <cfqueryparam value="#url.parkname#" cfsqltype="CF_SQL_VARCHAR">
</cfquery>

Then after changing code after uploading you come up with


<cfset request.live = "true"/>
<cfif request.live>
    <cfset request.dsn = "cfsnippetslive" />
<cfelse>
    <cfset request.dsn = "cfsnippetsdev" />
</cfif>

Then you go to a conference / Usergroup meeting / online web meeting


<cfscript>
    if (cgi.REMOTE_HOST is "mylivedomain.com") {
        request.dsn = "cfsnippetslive";
    }
    else {
        request.dsn = "cfsnippetsdev";
    }
</cfscript>

Then you chat with a DBA mate or get one in house


<cfstoredproc procedure="getParks" datasource="#request.dsn#">
    <cfprocparam value="#url.parkname#" cfsqltype="CF_SQL_VARCHAR">
    <cfprocresult name="GetParks">
</cfstoredproc>

Then...........

You go back to code your wrote back in stage one and think who the f**k wrote this shite, and because there were no comments you can blame everyone else execpt for yourself as you'd never write that now ;)

All I have to say is that we all develop, we can take this forward when people start to use Frameworks, Ant, Unit Testing, CI, Agile development etc.

We all have to admit it, our code has come along way from the day we started, and if you have only just started you'll laugh at this now saying I won't do that, and in 6 months time go back to old code and think, I've come along way since that day.


Did you like this post? Then buy me a beer

| View count: 231

CFML Developers Evolution Scribble

8 Responses leave one →
  1. marc esher
    Dec 13, 2009 at 11:51 PM

    I dunno Kev. I think my first query was more like "Select * From...."

  1. Big Mad Kev
    Dec 14, 2009 at 12:05 AM

    @marc D'oh well I actually copied and pasted that from the cf docs, so I'd hope new peeps wouldn't do it, but yes I was in that camp to. I may add a -1 step ;)

  1. Jonathan
    Dec 14, 2009 at 7:24 PM

    The final bit of code should be rails ;-)

  1. Rick
    Rick PERMALINK
    Dec 14, 2009 at 9:23 PM

    No Jonathon the correct answer would be CF on Wheels. Do you wonder why I say that?

    http://blog.multipliedbyinfinity.com/post.cfm/why-use-cfwheels-when-you-got-rails

  1. Jonathan
    Dec 14, 2009 at 9:31 PM

    hahaha. yeah, I was just joking...

  1. Big Mad Kev
    Dec 15, 2009 at 4:20 PM

    @Jonathan, I think the final bit should be Sunny yourself on a Beach and never having to work again :D

  1. Jose Galdamez
    Dec 15, 2009 at 8:10 PM

    After being away for about a year and a half, I took up my student job again working on some old CF website with over 600 CFM templates. Each one had an example 1 query. Those were good times, until we had to normalize the DB.

  1. John Whish
    Dec 16, 2009 at 11:14 AM

    "you can blame everyone else execpt for yourself" - this is a great reason why you _shouldn't_ use version control, then no-one can find out that it really was you! :D

Leave a Reply

Leave this field empty: