<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>The Accidental Developer &#187; ColdFusion</title>
	<atom:link href="http://osric.com/chris/accidental-developer/category/coldfusion/feed/" rel="self" type="application/rss+xml" />
	<link>http://osric.com/chris/accidental-developer</link>
	<description>What if Gregor Samsa awoke a computer programmer?</description>
	<lastBuildDate>Sat, 28 Jan 2012 23:13:31 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>CFFTP Transfers a Zero-Byte File and Throws a Timeout Error</title>
		<link>http://osric.com/chris/accidental-developer/2011/08/cfftp-transfers-a-zero-byte-file-and-throws-a-timeout-error/</link>
		<comments>http://osric.com/chris/accidental-developer/2011/08/cfftp-transfers-a-zero-byte-file-and-throws-a-timeout-error/#comments</comments>
		<pubDate>Mon, 22 Aug 2011 22:49:21 +0000</pubDate>
		<dc:creator>Chris Herdt</dc:creator>
				<category><![CDATA[ColdFusion]]></category>
		<category><![CDATA[cfftp]]></category>
		<category><![CDATA[ftp]]></category>

		<guid isPermaLink="false">http://osric.com/chris/accidental-developer/?p=472</guid>
		<description><![CDATA[Although I&#8217;ve used ColdFusion for 7+ years now, I&#8217;ve never used the cfftp tag before. Yesterday, I found a reason to try it out. I figured it would be as simple as cfhttp&#8211;and it was, with one exception (no pun intended). Here is my sample code: &#60;cfftp action="open" connection="test" server="ftp.osric.com" username="chris" password="********************" timeout="60" stoponerror="yes"&#62; &#60;cfftp [...]]]></description>
			<content:encoded><![CDATA[<p>Although I&#8217;ve used ColdFusion for 7+ years now, I&#8217;ve never used the cfftp tag before. Yesterday, I found a reason to try it out. I figured it would be as simple as cfhttp&#8211;and it was, with one exception (no pun intended).</p>
<p>Here is my sample code:</p>
<pre><code>&lt;cfftp action="open"
    connection="test"
    server="ftp.osric.com"
    username="chris"
    password="********************"
    timeout="60"
    stoponerror="yes"&gt;
&lt;cfftp
    connection = "test"
    action = "getFile"
    name = "downloadFile"
    transferMode = "binary"
    localFile = "S:\chris\handlebar-moustache.jpg"
    remoteFile = "handlebar-moustache.jpg"
    timeout="60"&gt;</code></pre>
<p>Here&#8217;s the error message it produced:<br />
<code>An error occurred during the FTP getFile operation.<br />
Error: getFile operation exceeded timeout.</code></p>
<p>However, the local file was still created (as a zero-byte file).</p>
<p>The solution, in my case, was to turn on passive mode (add attribute <code>passive="yes"</code> to the cfftp tag).</p>
<p><a href="http://slacksite.com/other/ftp.html">Active FTP vs. Passive FTP, a Definitive Explanation</a> has a brief explanation of the differences between active and passive FTP.</p>
]]></content:encoded>
			<wfw:commentRss>http://osric.com/chris/accidental-developer/2011/08/cfftp-transfers-a-zero-byte-file-and-throws-a-timeout-error/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Joes Goals Runs on Cold Fusion</title>
		<link>http://osric.com/chris/accidental-developer/2008/09/joes-goals-runs-on-cold-fusion/</link>
		<comments>http://osric.com/chris/accidental-developer/2008/09/joes-goals-runs-on-cold-fusion/#comments</comments>
		<pubDate>Fri, 19 Sep 2008 14:30:08 +0000</pubDate>
		<dc:creator>giblfiz</dc:creator>
				<category><![CDATA[ColdFusion]]></category>
		<category><![CDATA[Process]]></category>

		<guid isPermaLink="false">http://osric.com/chris/accidental-developer/?p=72</guid>
		<description><![CDATA[I use a pretty nifty little website called joe&#8217;s goals to track some of the things in my life. It ties in rather nicely with the google personal homepage, and has served me well for more than two years. It&#8217;s crashing today, and from the look of it, it runs on cold fusion. I must [...]]]></description>
			<content:encoded><![CDATA[<p>I use a pretty nifty little website called <a href="http://www.joesgoals.com/">joe&#8217;s goals</a> to track some of the things in my life. It ties in rather nicely with the google personal homepage, and has served me well for more than two years. It&#8217;s crashing today, and from the look of it, it runs on cold fusion. I must admit, I&#8217;m a little surprised. (Not that I have anything against cold fusion, you just don&#8217;t see it that often these days)</p>
]]></content:encoded>
			<wfw:commentRss>http://osric.com/chris/accidental-developer/2008/09/joes-goals-runs-on-cold-fusion/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Code Reviews</title>
		<link>http://osric.com/chris/accidental-developer/2008/09/code-reviews/</link>
		<comments>http://osric.com/chris/accidental-developer/2008/09/code-reviews/#comments</comments>
		<pubDate>Fri, 19 Sep 2008 03:18:45 +0000</pubDate>
		<dc:creator>Chris Herdt</dc:creator>
				<category><![CDATA[Best Practices]]></category>
		<category><![CDATA[ColdFusion]]></category>
		<category><![CDATA[Process]]></category>
		<category><![CDATA[code reviews]]></category>

		<guid isPermaLink="false">http://osric.com/chris/accidental-developer/?p=70</guid>
		<description><![CDATA[I recently attended a code review at Wharton. We&#8217;ve put together some code reviews at my job, but I know that Wharton has been doing formal code reviews for years and I wanted to check out their process to compare notes. For this particular code review they were looking at a small ColdFusion application developed [...]]]></description>
			<content:encoded><![CDATA[<p>I recently attended a code review at <a href="http://www.wharton.upenn.edu/">Wharton</a>. We&#8217;ve put together some code reviews at my job, but I know that Wharton has been doing formal code reviews for years and I wanted to check out their process to compare notes. For this particular code review they were looking at a small ColdFusion application developed using <a href="http://squidhead.riaforge.org/">Squidhead</a>.<br />
<span id="more-70"></span><br />
I was immediately surprised by how simple they kept it: no projector, no whiz-bang demo, just a handful of well-prepared developers with a stack of notes. Only the developer and a manager brought a laptop (and the second laptop may have been for my benefit, since I had not previously seen the code). The developer gave a brief summary of the application (its goals, functionality) and immediately handed things over to the reviewers.</p>
<p>The reviewers had clearly spent some time with the application, reviewing both the code and the interface. (I asked about this after the review, and one reviewer said he had spent 2-3 hours reviewing what was a relatively short and simple application. It is telling, I think, that attendance was voluntary&#8211;the reviewers in attendance were keen reviewers.) They got down to the level of detail where they brought up the date format (e.g. why did the developer use dd-mmm-yyyy instead of mm/dd/yyyy?).</p>
<p>The review was relatively structured while remaining casual in tone. They discussed CFCs, followed by other ColdFusion code, followed by user interface concerns and SQL. Each suggestion was backed up with a reason, e.g. avoid using evaluate() because it can lead to performance issues, or use mm/dd/yyyy because ~60% of the intended audience is most familiar with that format. In general, the topics covered fell into these categories: security, speed, standards/best practices, readability/maintainability, and user interface concerns.</p>
<p>It really seemed like a useful process to me. True, it added 12-18 developer hours to the project, but that is a small price to pay to avoid a possible security breach or server crash (not that any such vulnerabilities or flaws were found). The key, it seemed to me, was in the preparedness of the reviewers, who each came with comments in hand. Their preparedness, in turn, was helped by having basic guidelines as to what issues to look for.</p>
]]></content:encoded>
			<wfw:commentRss>http://osric.com/chris/accidental-developer/2008/09/code-reviews/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Generating iCal files with ColdFusion</title>
		<link>http://osric.com/chris/accidental-developer/2008/09/generating-ical-files-with-coldfusion/</link>
		<comments>http://osric.com/chris/accidental-developer/2008/09/generating-ical-files-with-coldfusion/#comments</comments>
		<pubDate>Wed, 03 Sep 2008 13:31:31 +0000</pubDate>
		<dc:creator>Chris Herdt</dc:creator>
				<category><![CDATA[ColdFusion]]></category>
		<category><![CDATA[coldfusion ical outlook]]></category>

		<guid isPermaLink="false">http://osric.com/chris/accidental-developer/?p=63</guid>
		<description><![CDATA[I&#8217;ve been using ColdFusion to generate and mail iCal (*.ics) files. This should be a cinch, as they are really pretty simple text files. However, when I receive the file in Microsoft Outlook 2007, I have no options to add it to my calendar and I see the following message: &#8220;As the meeting organizer, you [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been using ColdFusion to generate and mail iCal (*.ics) files. This should be a cinch, as they are really pretty simple text files. However, when I receive the file in Microsoft Outlook 2007, I have no options to add it to my calendar and I see the following message: <strong>&#8220;As the meeting organizer, you do not need to respond to the meeting.&#8221;</strong></p>
<p>This is peculiar, as my address is not the organizer specified in the iCal file, it is only the recipient of the iCal attachment. I&#8217;m going to keep looking into it, but I thought I&#8217;d mention it here in case anyone else is running into the same issue.</p>
<p>The two functions I&#8217;ve found online to assist in generating iCal files are:</p>
<ul>
<li><a href="http://cflib.org/udf/iCalUS">iCalUS</a> (via <a href="http://cflib.org/">CFLib.org</a>)</li>
<li>
<a href="http://www.planet-source-code.com/URLSEO/vb/scripts/ShowCode!asp/txtCodeId!71/lngWid!9/anyname.htm">CF_ICAL</a>  (via <a href="http://www.planet-source-code.com/">Planet Source Code</a>.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://osric.com/chris/accidental-developer/2008/09/generating-ical-files-with-coldfusion/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Checking for date-time conflicts</title>
		<link>http://osric.com/chris/accidental-developer/2008/04/checking-for-date-time-conflicts/</link>
		<comments>http://osric.com/chris/accidental-developer/2008/04/checking-for-date-time-conflicts/#comments</comments>
		<pubDate>Wed, 09 Apr 2008 21:15:22 +0000</pubDate>
		<dc:creator>Chris Herdt</dc:creator>
				<category><![CDATA[ColdFusion]]></category>
		<category><![CDATA[date]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[timestamps]]></category>

		<guid isPermaLink="false">http://osric.com/chris/accidental-developer/?p=22</guid>
		<description><![CDATA[It seems like I&#8217;ve worked on a lot of applications lately that involve time slots: room reservation systems, appointment schedulers, and so on. One thing that tripped me (and some other developers) up at first was checking for conflicting time slots. It turns out, there are a variety of possible conflicts: There are 5 unique [...]]]></description>
			<content:encoded><![CDATA[<p>It seems like I&#8217;ve worked on a lot of applications lately that involve time slots: room reservation systems, appointment schedulers, and so on. One thing that tripped me (and some other developers) up at first was checking for conflicting time slots. It turns out, there are a variety of possible conflicts:</p>
<p><img src="http://osric.com/chris/accidental-developer/wp-content/uploads/2008/04/conflicting-time-slots.png" alt="Conflicting Time Slots" /></p>
<p>There are 5 unique conflicts possible, and it seems like I&#8217;m always forgetting one.</p>
<p><span id="more-22"></span> Here&#8217;s a ColdFusion function that I&#8217;ve been using to check the database for conflicts:</p>
<p align="left">
<pre><code>&lt;cffunction name="hasConflicts" access="private" output="false" returntype="boolean" hint="Determines whether the specified start and end times have any conflicts"&gt;
&lt;cfargument name="startTime" type="date" required="true" hint="Start datetime timestamp"&gt;
&lt;cfargument name="endTime" type="date" required="true" hint="End datetime timestamp"&gt;
	<!--- Initialize local variables --->
	&lt;cfset var getConflicts = ""&gt;
	&lt;cfset var myResult = TRUE&gt;
	<!--- Run query --->
	&lt;cfquery name="getConflicts" datasource="#THIS.ds#"&gt;
		SELECT id
		FROM reservations
		WHERE (
			(
				start_timestamp &gt;= &lt;cfqueryparam value="#ARGUMENTS.startTime#" cfsqltype="cf_sql_timestamp"&gt; AND
				end_timestamp &lt;= &lt;cfqueryparam value="#ARGUMENTS.endTime#" cfsqltype="cf_sql_timestamp"&gt;
			) OR (
				start_timestamp &lt;= &lt;cfqueryparam value="#ARGUMENTS.startTime#" cfsqltype="cf_sql_timestamp"&gt; AND
				end_timestamp &gt;= &lt;cfqueryparam value="#ARGUMENTS.endTime#" cfsqltype="cf_sql_timestamp"&gt;
			) OR (
				start_timestamp &lt; &lt;cfqueryparam value="#ARGUMENTS.endTime#" cfsqltype="cf_sql_timestamp"&gt; AND
				end_timestamp &gt;= &lt;cfqueryparam value="#ARGUMENTS.endTime#" cfsqltype="cf_sql_timestamp"&gt;
			) OR (
				start_timestamp &lt;= &lt;cfqueryparam value="#ARGUMENTS.startTime#" cfsqltype="cf_sql_timestamp"&gt; AND
				end_timestamp &gt; &lt;cfqueryparam value="#ARGUMENTS.startTime#" cfsqltype="cf_sql_timestamp"&gt;
			)
		)
	&lt;/cfquery&gt;
	<!--- If there are no conflicting records, set result to FALSE --->
	&lt;cfif getConflictingReservations.recordCount EQ 0&gt;
		&lt;cfset myResult = FALSE&gt;
	&lt;/cfif&gt;
	<!--- Return result (boolean) --->
	&lt;cfreturn myResult&gt;
&lt;/cffunction&gt;</code>
</pre>
<p>There might be a more elegant query, but this one works. I&#8217;m posting it here for my own future reference, and anyone else that might find it useful.</p>
]]></content:encoded>
			<wfw:commentRss>http://osric.com/chris/accidental-developer/2008/04/checking-for-date-time-conflicts/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Object Overhead in ColdFusion</title>
		<link>http://osric.com/chris/accidental-developer/2008/03/object-overhead-in-coldfusion/</link>
		<comments>http://osric.com/chris/accidental-developer/2008/03/object-overhead-in-coldfusion/#comments</comments>
		<pubDate>Sun, 09 Mar 2008 18:43:33 +0000</pubDate>
		<dc:creator>Chris Herdt</dc:creator>
				<category><![CDATA[ColdFusion]]></category>
		<category><![CDATA[object-oriented programming]]></category>

		<guid isPermaLink="false">http://osric.com/chris/accidental-developer/?p=6</guid>
		<description><![CDATA[I have been trying to improve the speed of a ColdFusion application. It was written by a part-timer, a Java developer who was new to ColdFusion. He wrote the code almost entirely in cfscript, and he used CFC objects extensively. In fact, it seems that he overused CFC objects—to the point where the server slows [...]]]></description>
			<content:encoded><![CDATA[<p>I have been trying to improve the speed of a ColdFusion application. It was written by a part-timer, a Java developer who was new to ColdFusion. He wrote the code almost entirely in cfscript, and he used CFC objects extensively. In fact, it seems that he overused CFC objects—to the point where the server slows to a crawl.</p>
<p><span id="more-6"></span>The application is a room reservation tool. The interface displays a table/grid of rooms and their availability throughout the day. The grid is a object, each room within the grid is an object, and each reservation within the room is an object. With 20 rooms and up to 4 reservations per room, there were easily up to 81 complex objects instantiated per page load. During testing, the pages often took 5-10 seconds to load. Under load, the pages took minutes to load. Memory use skyrocketed, and I had to run garbage collection manually via the ColdFusion server monitor to get it to respond to further requests.</p>
<p>I found Robert Munn&#8217;s series of blog posts:</p>
<ul>
<li><a href="http://blog.emergentpath.com/index.cfm/2008/1/9/Object-instantiation-and-heap-size-in-ColdFusion">Object instantiation and heap size in ColdFusion</a></li>
<li><a href="http://blog.emergentpath.com/index.cfm/2008/1/11/Object-instantiation-and-heap-size-in-ColdFusion--Part-II">Object instantiation and heap size in ColdFusion &#8211; Part II</a></li>
<li><a href="http://blog.emergentpath.com/index.cfm/2008/1/12/Object-instantiation-and-heap-size-in-ColdFusion--Part-III">Object instantiation and heap size in ColdFusion &#8211; Part III</a></li>
<li><a href="http://blog.emergentpath.com/index.cfm/2008/1/12/Object-instantiation-and-heap-size-in-ColdFusion--Part-IV">Object instantiation and heap size in ColdFusion &#8211; Part IV</a></li>
</ul>
<p>His observations are very similar to mine (although the decline in server performance, in my experience, was far more drastic).</p>
<p>I haven&#8217;t yet addressed the all the issues in the room reservation application, but as a proof-of-concept I re-created the interface using a single object—a ColdFusion query object—rather than the original hierarchy of objects-within-objects-within-objects. The new page loaded 10 times faster than the original.</p>
<p>I was concerned that I hadn&#8217;t really found the problem, though. My new code was circumventing all the object instantiation, but it was circumventing a lot of other logic, too. Before starting a major revision, I needed more evidence that object overhead was indeed one of the performance issues.</p>
<p>I created 2 pages that do exactly the same thing: one page reads an XML file of U.S. state data and loops through it to find the Great Lakes State (Michigan) and the Keystone State (Pennsylvania). One page creates a state object for each record in the XML, and the other just works with the XML data directly:</p>
<ul>
<li>Using objects: 129 milliseconds</li>
<li>Without objects: <em>1006 milliseconds</em></li>
</ul>
<p>(Times listed are averages for 1000 runs. The file are here: <a href="http://osric.com/chris/coldfusion/states/">ColdFusion objects performance test</a>)</p>
<p>Does this mean developers should avoid object-oriented code in ColdFusion? I don&#8217;t think so. But I don&#8217;t think developers should create objects willy-nilly when they aren&#8217;t necessary. The room reservation system, for example, doesn&#8217;t need to create 80 reservation objects <em>just to display a list</em>, but it makes sense to create a single reservation object once the user drills down to view or edit the specifics of a single reservation.</p>
]]></content:encoded>
			<wfw:commentRss>http://osric.com/chris/accidental-developer/2008/03/object-overhead-in-coldfusion/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

