Testing and Debugging the easy way: The debug flag

Setting and accomodating for a debug flag is one of the easiest ways to turn your script or application into "debug mode". One such method is to allow for a dedicated query string parameter, say debug, where in it's presence, your script runs in "debug mode".

Using a ColdFusion example, let's say we want to alter the conditions of a query based on the presence or lack-of the query string debug parameter. The example query selects a list of all users in a database table, in preparation for a mass email. In this situation, a system for simple debugging is crucial.

<cfquery name="users">
    SELECT fname, lname, email
    FROM user
    <cfif isDefined("url.debug")>WHERE email = 'testuser@test.com'</cfif>
</cfquery>

Now, all code in your script, which depends on the users recordset, will only be referencing the "debug" version of the query.

Subscribe

  • RSS Feed for Posts


This entry was tagged .

Updated: 2012-04-16

Phil LaNasa

Leave a Reply

Your email address will not be published. Required fields are marked *


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <font color="" face="" size=""> <span style="">