<?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>Polymorphism &#187; ColdFusion</title>
	<atom:link href="http://www.clearcrystalmedia.com/pm/category/programming/coldfusion/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.clearcrystalmedia.com/pm</link>
	<description>using the right technology at the right time</description>
	<lastBuildDate>Tue, 29 Nov 2011 13:53:55 +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>cfspreadsheet for Railo</title>
		<link>http://www.clearcrystalmedia.com/pm/cfspreadsheet-for-railo/</link>
		<comments>http://www.clearcrystalmedia.com/pm/cfspreadsheet-for-railo/#comments</comments>
		<pubDate>Thu, 02 Jun 2011 21:01:42 +0000</pubDate>
		<dc:creator>Chris Peters</dc:creator>
				<category><![CDATA[ColdFusion]]></category>
		<category><![CDATA[andy jarrett]]></category>
		<category><![CDATA[ccm]]></category>
		<category><![CDATA[cf]]></category>
		<category><![CDATA[cfml]]></category>
		<category><![CDATA[cfpoi]]></category>
		<category><![CDATA[cfspreadsheet]]></category>
		<category><![CDATA[chris peters]]></category>
		<category><![CDATA[clear crystal media]]></category>
		<category><![CDATA[excel]]></category>
		<category><![CDATA[matt woodward]]></category>
		<category><![CDATA[polymorphism]]></category>
		<category><![CDATA[railo]]></category>
		<category><![CDATA[spreadsheet]]></category>

		<guid isPermaLink="false">http://www.clearcrystalmedia.com/pm/?p=594</guid>
		<description><![CDATA[<p>If you've made the switch to <a href="http://getrailo.org/">Railo</a> and find yourself missing the <code>&#60;cfspreadsheet&#62;</code> tag and its related functions, don't fear. Andy Jarrett released an <a title="cfspreadsheet for Railo" href="http://www.andyjarrett.co.uk/blog/index.cfm/2011/1/2/cfspreadsheet-for-Railo">extension for Railo</a> early this year to fill in that gap.</p>
<p>Read on to find out more.</p>]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;ve made the switch to <a href="http://getrailo.org/">Railo</a> and find yourself missing the <code>&lt;cfspreadsheet&gt;</code> tag and its related functions, don&#8217;t fear. Andy Jarrett released an <a title="cfspreadsheet for Railo" href="http://www.andyjarrett.co.uk/blog/index.cfm/2011/1/2/cfspreadsheet-for-Railo">extension for Railo</a> early this year to fill in that gap.</p>
<p>The extension is based on the <a href="http://code.google.com/p/cfpoi/">CFPOI</a> project started by Matt Woodward. But what&#8217;s been really cool about the Railo extension project is that it has incorporated some major bug fixes and filled in some missing features. CFPOI appeared to lose steam some time ago, so it&#8217;s been nice to see the project breathe some extra life.</p>
<p>In addition to the link above, the <a title="cfspreadsheet for Railo GitHub repo" href="https://github.com/andyj/RailoExtensionProvider">GitHub repo</a> is the place to look if you want to watch it, report issues, and contribute.</p>

<!-- start wp-tags-to-technorati 1.01 -->

<p class='technorati-tags'>Technorati Tags: <a class='technorati-link' href='http://technorati.com/tag/andy+jarrett' rel='tag' target='_self'>andy jarrett</a>, <a class='technorati-link' href='http://technorati.com/tag/ccm' rel='tag' target='_self'>ccm</a>, <a class='technorati-link' href='http://technorati.com/tag/cf' rel='tag' target='_self'>cf</a>, <a class='technorati-link' href='http://technorati.com/tag/cfml' rel='tag' target='_self'>cfml</a>, <a class='technorati-link' href='http://technorati.com/tag/cfpoi' rel='tag' target='_self'>cfpoi</a>, <a class='technorati-link' href='http://technorati.com/tag/cfspreadsheet' rel='tag' target='_self'>cfspreadsheet</a>, <a class='technorati-link' href='http://technorati.com/tag/chris+peters' rel='tag' target='_self'>chris peters</a>, <a class='technorati-link' href='http://technorati.com/tag/clear+crystal+media' rel='tag' target='_self'>clear crystal media</a>, <a class='technorati-link' href='http://technorati.com/tag/ColdFusion' rel='tag' target='_self'>ColdFusion</a>, <a class='technorati-link' href='http://technorati.com/tag/excel' rel='tag' target='_self'>excel</a>, <a class='technorati-link' href='http://technorati.com/tag/matt+woodward' rel='tag' target='_self'>matt woodward</a>, <a class='technorati-link' href='http://technorati.com/tag/polymorphism' rel='tag' target='_self'>polymorphism</a>, <a class='technorati-link' href='http://technorati.com/tag/railo' rel='tag' target='_self'>railo</a>, <a class='technorati-link' href='http://technorati.com/tag/spreadsheet' rel='tag' target='_self'>spreadsheet</a></p>

<!-- end wp-tags-to-technorati -->
]]></content:encoded>
			<wfw:commentRss>http://www.clearcrystalmedia.com/pm/cfspreadsheet-for-railo/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Super-slow ColdFusion image processing</title>
		<link>http://www.clearcrystalmedia.com/pm/super-slow-coldfusion-image-processing/</link>
		<comments>http://www.clearcrystalmedia.com/pm/super-slow-coldfusion-image-processing/#comments</comments>
		<pubDate>Mon, 08 Nov 2010 14:00:36 +0000</pubDate>
		<dc:creator>Chris Peters</dc:creator>
				<category><![CDATA[ColdFusion]]></category>
		<category><![CDATA[ColdFusion on Wheels]]></category>
		<category><![CDATA[ccm]]></category>
		<category><![CDATA[cfimage]]></category>
		<category><![CDATA[cfml]]></category>
		<category><![CDATA[cfwheels]]></category>
		<category><![CDATA[chris peters]]></category>
		<category><![CDATA[clear crystal media]]></category>
		<category><![CDATA[coldfusion on wheels]]></category>
		<category><![CDATA[imagescaletofit]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[polymorphism]]></category>
		<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://www.clearcrystalmedia.com/pm/?p=557</guid>
		<description><![CDATA[<p>I was excited to finally take some time to add the ability for people to upload screenshots in the <a href="http://cfwheels.org/sites">ColdFusion on Wheels Site Directory</a> when I ran into a big problem. When I started sending large screenshots to ColdFusion's <a href="http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-7975.html"><code>ImageScaleToWidth()</code></a>, it would take 30+ seconds to do the processing. Unacceptable.</p>
<p>Read on to see how I ended up tackling this problem with <code>&#60;cfthread&#62;</code>]]></description>
			<content:encoded><![CDATA[<p>I was excited to finally take some time to add the ability for people to upload screenshots in the <a href="http://cfwheels.org/sites">ColdFusion on Wheels Site Directory</a> when I ran into a big problem. When I started sending large screenshots to ColdFusion&#8217;s <a href="http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-7975.html"><code>ImageScaleToWidth()</code></a>, it would take 30+ seconds to do the processing. Unacceptable.</p>
<p>As it turns out, this slowness was a combination of processing a PNG on my Linux server. When I tried uploading a JPEG of the same size, it would process in under 5 seconds. I don&#8217;t know if PNG processing causes similar issues on Windows or Mac systems, so post in the comments if you have experienced similar issues on those <abbr title="Operating System">OS</abbr>es.</p>
<h2>What I tried to fix it</h2>
<p>Here&#8217;s where the fun starts. I tried a number of things to get around this constraint and try to allow for users to still upload PNGs without the server timing out.</p>
<h3>Tweaking image quality settings</h3>
<p>There is an <code>interpolation</code> argument that you can pass into the image functions with different options for algorithms or canned settings like <code>highestQuality</code>, <code>highQuality</code>, and <code>mediumQuality</code>. I had to get the settings so low that the images started looking jacked up. Not exactly how I want people visiting <a href="http://cfwheels.org/">cfwheels.org</a> to think&#8230;</p>
<h3>Image <abbr title="ColdFusion Component">CFC</abbr></h3>
<p>This library has been great through the years as it adds an easy <abbr title="Application Programming Interface">API</abbr> for such awesome functionality. The only problem is that the underlying Java libraries it uses do a fairly poor job at maintaining quality while resizing images. Image quality is one area where the built-in ColdFusion functionality really shines.</p>
<h3>Directory Watcher event gateway</h3>
<p>I don&#8217;t know why I went down this route, but I decided to try implementing an instance of the Directory Watcher event gateway. I found a <a href="http://www.coldfusionjedi.com/index.cfm/2007/10/29/DirectoryWatcher-and-ColdFusion-Image-Manipulation-Example">really helpful article by Ray Camden</a> that took most of the work out of this while helping me learn how to actually do it.</p>
<p>The watcher would check the image queue periodically for new files and resize them from there. It was pretty cool, but not really as good as <code>&lt;cfthread&gt;</code>&#8230;</p>
<h3>Offload the resizing task using &lt;cfthread&gt;</h3>
<p>I had tried <code>&lt;cfthread&gt;</code> earlier in the project to split the task into 3 parts (full, medium, and thumb). I then called <code>&lt;cfthread action=&quot;join&quot;&gt;</code> at the end of that bit. As it turned out, the thread would cause the page load to wait until the slowest operation was done, which didn&#8217;t help my page load time very much at all. (It may have actually ended up being worse.)</p>
<p>But as it turns out, if you simply don&#8217;t call <code>action=&quot;join&quot;</code> in your script, <abbr title="ColdFusion">CF</abbr> will take that thread past your page load and continue processing in the background. All I had to do was remove that line and update my database with a status indicating that the images couldn&#8217;t be show until the process was done. (The threaded process updates the flag in the database at the end.)</p>
<p>Here&#8217;s a little code from my <code>siteScreenshot</code> Wheels model to give you an idea of what happens:</p>

<div class="wp_syntax"><div class="code"><pre class="cfm" style="font-family:monospace;"><span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cffunction</span> <span style="color: #0000FF;">name</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;setImageSizes&quot;</span> <span style="color: #0000FF;">access</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;private&quot;</span> <span style="color: #0000FF;">hint</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;Resizes image in queue, moves new resized files to 'production,' and removes `tempUploadId` from DB.&quot;</span><span style="color: #0000FF;">&gt;</span></span>
&nbsp;
	<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfset</span> <span style="color: #000000; font-weight: bold;">var</span> loc <span style="color: #0000FF;">=</span> <span style="color: #0000FF;">&#123;</span><span style="color: #0000FF;">&#125;</span><span style="color: #0000FF;">&gt;</span></span>
&nbsp;
	<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfif</span> isUploadingNewFile<span style="color: #0000FF;">&#40;</span><span style="color: #0000FF;">&#41;</span><span style="color: #0000FF;">&gt;</span></span>
		<span style="color: #808080; font-style: italic;">&lt;!--- Read image ---&gt;</span>
		<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cflog</span> file<span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;siteScreenshotResize&quot;</span> <span style="color: #0000FF;">text</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;Reading #this.imageFile#&quot;</span><span style="color: #0000FF;">&gt;</span></span>
		<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfset</span> loc.image <span style="color: #0000FF;">=</span> ImageRead<span style="color: #0000FF;">&#40;</span><span style="color: #009900;">&quot;#variables.UPLOAD_QUEUE_DIRECTORY##this.imageFile#&quot;</span><span style="color: #0000FF;">&#41;</span><span style="color: #0000FF;">&gt;</span></span>
&nbsp;
		<span style="color: #808080; font-style: italic;">&lt;!--- Turn on antialiasing to improve image quality ---&gt;</span>
		<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfset</span> ImageSetAntialiasing<span style="color: #0000FF;">&#40;</span>loc.image, <span style="color: #009900;">&quot;on&quot;</span><span style="color: #0000FF;">&#41;</span><span style="color: #0000FF;">&gt;</span></span>
&nbsp;
		<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span>cfthread</span>
<span style="color: #333333;">			<span style="color: #0000FF;">action</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;run&quot;</span></span>
<span style="color: #333333;">			<span style="color: #0000FF;">name</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;loc[#CreateUuid()#]&quot;</span></span>
<span style="color: #333333;">			priority<span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;low&quot;</span></span>
<span style="color: #333333;">			image<span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;#loc.image#&quot;</span></span>
<span style="color: #333333;">			dsn<span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;#get('dataSourceName')#&quot;</span></span>
<span style="color: #333333;">			thisId<span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;#this.id#&quot;</span></span>
<span style="color: #333333;">		<span style="color: #0000FF;">&gt;</span></span>
			<span style="color: #808080; font-style: italic;">&lt;!--- Resize full size ---&gt;</span>
			<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfset</span> resizeImage<span style="color: #0000FF;">&#40;</span>image, <span style="color: #009900;">&quot;full&quot;</span>, <span style="color: #FF0000;">1</span><span style="color: #0000FF;">&#41;</span><span style="color: #0000FF;">&gt;</span></span>
			<span style="color: #808080; font-style: italic;">&lt;!--- Resize medium size ---&gt;</span>
			<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfset</span> resizeImage<span style="color: #0000FF;">&#40;</span>image, <span style="color: #009900;">&quot;medium&quot;</span>, <span style="color: #FF0000;">0.9</span><span style="color: #0000FF;">&#41;</span><span style="color: #0000FF;">&gt;</span></span>
			<span style="color: #808080; font-style: italic;">&lt;!--- Resize thumbnail ---&gt;</span>
			<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfset</span> resizeThumbnail<span style="color: #0000FF;">&#40;</span>image, <span style="color: #009900;">&quot;thumb&quot;</span>, <span style="color: #FF0000;">0.8</span><span style="color: #0000FF;">&#41;</span><span style="color: #0000FF;">&gt;</span></span>
&nbsp;
			<span style="color: #808080; font-style: italic;">&lt;!--- Update DB to reflect new status</span>
<span style="color: #808080; font-style: italic;">				(Use query because model doesn't seem to be working inside of thread) ---&gt;</span>
			<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfquery</span> <span style="color: #0000FF;">datasource</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;#dsn#&quot;</span><span style="color: #0000FF;">&gt;</span></span>
				UPDATE
					sitescreenshots
				SET
					tempuploadid = NULL
				WHERE
					id =
						<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfqueryparam</span> cfsqltype<span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;cf_sql_integer&quot;</span> <span style="color: #0000FF;">value</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;#thisId#&quot;</span><span style="color: #0000FF;">&gt;</span></span>
			<span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cfquery</span><span style="color: #0000FF;">&gt;</span></span>
		<span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span>cfthread<span style="color: #0000FF;">&gt;</span></span>
	<span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cfif</span><span style="color: #0000FF;">&gt;</span></span>
&nbsp;
<span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cffunction</span><span style="color: #0000FF;">&gt;</span></span></pre></div></div>


<!-- start wp-tags-to-technorati 1.01 -->

<p class='technorati-tags'>Technorati Tags: <a class='technorati-link' href='http://technorati.com/tag/ccm' rel='tag' target='_self'>ccm</a>, <a class='technorati-link' href='http://technorati.com/tag/cfimage' rel='tag' target='_self'>cfimage</a>, <a class='technorati-link' href='http://technorati.com/tag/cfml' rel='tag' target='_self'>cfml</a>, <a class='technorati-link' href='http://technorati.com/tag/cfwheels' rel='tag' target='_self'>cfwheels</a>, <a class='technorati-link' href='http://technorati.com/tag/chris+peters' rel='tag' target='_self'>chris peters</a>, <a class='technorati-link' href='http://technorati.com/tag/clear+crystal+media' rel='tag' target='_self'>clear crystal media</a>, <a class='technorati-link' href='http://technorati.com/tag/ColdFusion' rel='tag' target='_self'>ColdFusion</a>, <a class='technorati-link' href='http://technorati.com/tag/coldfusion+on+wheels' rel='tag' target='_self'>coldfusion on wheels</a>, <a class='technorati-link' href='http://technorati.com/tag/imagescaletofit' rel='tag' target='_self'>imagescaletofit</a>, <a class='technorati-link' href='http://technorati.com/tag/performance' rel='tag' target='_self'>performance</a>, <a class='technorati-link' href='http://technorati.com/tag/polymorphism' rel='tag' target='_self'>polymorphism</a>, <a class='technorati-link' href='http://technorati.com/tag/web+development' rel='tag' target='_self'>web development</a></p>

<!-- end wp-tags-to-technorati -->
]]></content:encoded>
			<wfw:commentRss>http://www.clearcrystalmedia.com/pm/super-slow-coldfusion-image-processing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bug fixes in ColdFISH on Wheels version 0.3</title>
		<link>http://www.clearcrystalmedia.com/pm/bug-fixes-coldfish-on-wheels-version-0-3/</link>
		<comments>http://www.clearcrystalmedia.com/pm/bug-fixes-coldfish-on-wheels-version-0-3/#comments</comments>
		<pubDate>Thu, 01 Jul 2010 01:36:46 +0000</pubDate>
		<dc:creator>Chris Peters</dc:creator>
				<category><![CDATA[ColdFusion]]></category>
		<category><![CDATA[ColdFusion on Wheels]]></category>
		<category><![CDATA[cfwheels]]></category>
		<category><![CDATA[coldfish]]></category>
		<category><![CDATA[coldfish on wheels]]></category>
		<category><![CDATA[coldfusion on wheels]]></category>
		<category><![CDATA[dave shuck]]></category>
		<category><![CDATA[expandpath]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[plugins]]></category>

		<guid isPermaLink="false">http://www.clearcrystalmedia.com/pm/?p=486</guid>
		<description><![CDATA[<p>I went to deploy my new <a href="http://cfwheels.org/plugins/listing/40">ColdFISH on Wheels plugin</a> on my Linux server and got a curious error. Especially if you're using Linux, you'll want to upgrade to ColdFISH on Wheels 0.3 <abbr title="as soon as possible">ASAP</abbr>.</p>
<p>What happened? Read on to find out.</p>]]></description>
			<content:encoded><![CDATA[<p>I went to deploy my new <a href="http://cfwheels.org/plugins/listing/40">ColdFISH on Wheels plugin</a> on my Linux server and got a curious error. Especially if you&#8217;re using Linux, you&#8217;ll want to upgrade to ColdFISH on Wheels 0.3 <abbr title="as soon as possible">ASAP</abbr>.</p>
<p>So what was the error? It involved <a href="http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-7c67.html"><code>ExpandPath()</code></a>. Fortunately, <a title="Strange behavior with ColdFusion ExpandPath() when using Symbolic Links" href="http://daveshuck.instantspot.com/blog/2009/09/23/Strange-behavior-with-ColdFusion-ExpandPath-when-using-Symbolic-Links">Dave Shuck&#8217;s blog saved the day for me</a>. Evidently <code>"/config/coldfishconfig.xml"</code> means something different on Linux than <code>"./config/coldfishconfig.xml"</code>. It was really strange what the first string translated to on my server. It was some weird path involving <code>"shared://"</code>.</p>
<p>Go figure.</p>
<p>How the hell did any of us ever get by before Google got really good and  everyone blogged about their solutions to problems?</p>

<!-- start wp-tags-to-technorati 1.01 -->

<p class='technorati-tags'>Technorati Tags: <a class='technorati-link' href='http://technorati.com/tag/cfwheels' rel='tag' target='_self'>cfwheels</a>, <a class='technorati-link' href='http://technorati.com/tag/coldfish' rel='tag' target='_self'>coldfish</a>, <a class='technorati-link' href='http://technorati.com/tag/coldfish+on+wheels' rel='tag' target='_self'>coldfish on wheels</a>, <a class='technorati-link' href='http://technorati.com/tag/ColdFusion' rel='tag' target='_self'>ColdFusion</a>, <a class='technorati-link' href='http://technorati.com/tag/coldfusion+on+wheels' rel='tag' target='_self'>coldfusion on wheels</a>, <a class='technorati-link' href='http://technorati.com/tag/dave+shuck' rel='tag' target='_self'>dave shuck</a>, <a class='technorati-link' href='http://technorati.com/tag/expandpath' rel='tag' target='_self'>expandpath</a>, <a class='technorati-link' href='http://technorati.com/tag/linux' rel='tag' target='_self'>linux</a>, <a class='technorati-link' href='http://technorati.com/tag/plugin' rel='tag' target='_self'>plugin</a>, <a class='technorati-link' href='http://technorati.com/tag/plugins' rel='tag' target='_self'>plugins</a></p>

<!-- end wp-tags-to-technorati -->
]]></content:encoded>
			<wfw:commentRss>http://www.clearcrystalmedia.com/pm/bug-fixes-coldfish-on-wheels-version-0-3/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Structuring CFCs a little like Ruby</title>
		<link>http://www.clearcrystalmedia.com/pm/structuring-cfcs-like-ruby/</link>
		<comments>http://www.clearcrystalmedia.com/pm/structuring-cfcs-like-ruby/#comments</comments>
		<pubDate>Wed, 19 May 2010 02:36:19 +0000</pubDate>
		<dc:creator>Chris Peters</dc:creator>
				<category><![CDATA[ColdFusion]]></category>
		<category><![CDATA[ColdFusion on Wheels]]></category>
		<category><![CDATA[cfml]]></category>
		<category><![CDATA[cfwheels]]></category>
		<category><![CDATA[coldfusion on wheels]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ror]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[rubyonrails]]></category>
		<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://www.clearcrystalmedia.com/pm/?p=465</guid>
		<description><![CDATA[<p>As I hit the books and learned about Ruby on Rails a couple years ago, there was one thing that I admired about how Ruby handles public and private sections of classes.</p>
<p>How can I take a lesson from Ruby and apply it to my CFML coding? I'm glad that you asked! Read on for more details.</p>]]></description>
			<content:encoded><![CDATA[<p>As I hit the books and learned about Ruby on Rails a couple years ago, there was one thing that I admired about how Ruby handles public and private sections of classes.</p>
<p>Take this, for example:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">class</span> PostsController <span style="color:#006600; font-weight:bold;">&lt;</span> ApplicationController
    before_filter <span style="color:#ff3333; font-weight:bold;">:find_post</span>, <span style="color:#ff3333; font-weight:bold;">:only</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:show</span>, <span style="color:#ff3333; font-weight:bold;">:edit</span>, <span style="color:#ff3333; font-weight:bold;">:update</span>, <span style="color:#ff3333; font-weight:bold;">:destroy</span><span style="color:#006600; font-weight:bold;">&#93;</span>
&nbsp;
    <span style="color:#9966CC; font-weight:bold;">def</span> show
        <span style="color:#008000; font-style:italic;"># ...</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
    <span style="color:#9966CC; font-weight:bold;">def</span> edit
        <span style="color:#008000; font-style:italic;"># ...</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
    <span style="color:#9966CC; font-weight:bold;">def</span> update
        <span style="color:#008000; font-style:italic;"># ...</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
    <span style="color:#9966CC; font-weight:bold;">def</span> destroy
        <span style="color:#008000; font-style:italic;"># ...</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
    private
&nbsp;
    <span style="color:#9966CC; font-weight:bold;">def</span> find_post
        <span style="color:#0066ff; font-weight:bold;">@post</span> = Post.<span style="color:#9900CC;">find</span><span style="color:#006600; font-weight:bold;">&#40;</span>params<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:id</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>Using the <code>private</code> keyword, the interpreter knows that all methods defined in the section afterward are private. It&#8217;s a pretty clean way of demarcating different blocks of code that have different roles.</p>
<p>While we have no such set of keywords for <abbr title="ColdFusion Markup Language">CFML</abbr> except at the function level, why not use comments to do similar structuring of your <abbr title="ColdFusion Component">CFC</abbr>s?</p>

<div class="wp_syntax"><div class="code"><pre class="cfm" style="font-family:monospace;"><span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfcomponent</span> extends<span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;Controller&quot;</span><span style="color: #0000FF;">&gt;</span></span>
&nbsp;
    <span style="color: #808080; font-style: italic;">&lt;!-------------------------------------&gt;</span>
    <span style="color: #808080; font-style: italic;">&lt;!--- Public ---&gt;</span>
&nbsp;
    <span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cffunction</span> <span style="color: #0000FF;">name</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;init&quot;</span><span style="color: #0000FF;">&gt;</span></span>
        <span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfset</span> filters<span style="color: #0000FF;">&#40;</span>through<span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;findPost, only=&quot;</span>show,edit,update,destroy<span style="color: #009900;">&quot;)&gt;</span></span>
    <span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cffunction</span><span style="color: #0000FF;">&gt;</span></span>
&nbsp;
    <span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cffunction</span> <span style="color: #0000FF;">name</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;show&quot;</span><span style="color: #0000FF;">&gt;</span></span>
        <span style="color: #808080; font-style: italic;">&lt;!--- ... ---&gt;</span>
    <span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cffunction</span><span style="color: #0000FF;">&gt;</span></span>
&nbsp;
    <span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cffunction</span> <span style="color: #0000FF;">name</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;edit&quot;</span><span style="color: #0000FF;">&gt;</span></span>
        <span style="color: #808080; font-style: italic;">&lt;!--- ... ---&gt;</span>
    <span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cffunction</span><span style="color: #0000FF;">&gt;</span></span>
&nbsp;
    <span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cffunction</span> <span style="color: #0000FF;">name</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;update&quot;</span><span style="color: #0000FF;">&gt;</span></span>
        <span style="color: #808080; font-style: italic;">&lt;!--- ... ---&gt;</span>
    <span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cffunction</span><span style="color: #0000FF;">&gt;</span></span>
&nbsp;
    <span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cffunction</span> <span style="color: #0000FF;">name</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;destroy&quot;</span><span style="color: #0000FF;">&gt;</span></span>
        <span style="color: #808080; font-style: italic;">&lt;!--- ... ---&gt;</span>
    <span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cffunction</span><span style="color: #0000FF;">&gt;</span></span>
&nbsp;
    <span style="color: #808080; font-style: italic;">&lt;!-------------------------------------&gt;</span>
    <span style="color: #808080; font-style: italic;">&lt;!--- Private ---&gt;</span>
&nbsp;
    <span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cffunction</span> <span style="color: #0000FF;">name</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;findPost&quot;</span> <span style="color: #0000FF;">access</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;private&quot;</span><span style="color: #0000FF;">&gt;</span></span>
        <span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfset</span> post <span style="color: #0000FF;">=</span> model<span style="color: #0000FF;">&#40;</span><span style="color: #009900;">&quot;post&quot;</span><span style="color: #0000FF;">&#41;</span>.findByKey<span style="color: #0000FF;">&#40;</span>params.key<span style="color: #0000FF;">&#41;</span><span style="color: #0000FF;">&gt;</span></span>
    <span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cffunction</span><span style="color: #0000FF;">&gt;</span></span>
&nbsp;
<span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cfcomponent</span><span style="color: #0000FF;">&gt;</span></span></pre></div></div>

<p>A perfect translation? No. But an idea on how to use some simple comments to make your life easier when maintaining your code in the future.</p>
<p>I&#8217;ve taken it a step farther and also have been creating &#8220;Filters&#8221; sections for filters, just before &#8220;Private&#8221; methods.</p>

<!-- start wp-tags-to-technorati 1.01 -->

<p class='technorati-tags'>Technorati Tags: <a class='technorati-link' href='http://technorati.com/tag/cfml' rel='tag' target='_self'>cfml</a>, <a class='technorati-link' href='http://technorati.com/tag/cfwheels' rel='tag' target='_self'>cfwheels</a>, <a class='technorati-link' href='http://technorati.com/tag/ColdFusion' rel='tag' target='_self'>ColdFusion</a>, <a class='technorati-link' href='http://technorati.com/tag/coldfusion+on+wheels' rel='tag' target='_self'>coldfusion on wheels</a>, <a class='technorati-link' href='http://technorati.com/tag/Programming' rel='tag' target='_self'>Programming</a>, <a class='technorati-link' href='http://technorati.com/tag/rails' rel='tag' target='_self'>rails</a>, <a class='technorati-link' href='http://technorati.com/tag/ror' rel='tag' target='_self'>ror</a>, <a class='technorati-link' href='http://technorati.com/tag/ruby' rel='tag' target='_self'>ruby</a>, <a class='technorati-link' href='http://technorati.com/tag/rubyonrails' rel='tag' target='_self'>rubyonrails</a>, <a class='technorati-link' href='http://technorati.com/tag/web+development' rel='tag' target='_self'>web development</a></p>

<!-- end wp-tags-to-technorati -->
]]></content:encoded>
			<wfw:commentRss>http://www.clearcrystalmedia.com/pm/structuring-cfcs-like-ruby/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Full CFScript CFCs aren&#8217;t yet where they need to be</title>
		<link>http://www.clearcrystalmedia.com/pm/full-cfscript-cfcs-not-where-they-need-to-be/</link>
		<comments>http://www.clearcrystalmedia.com/pm/full-cfscript-cfcs-not-where-they-need-to-be/#comments</comments>
		<pubDate>Sun, 18 Apr 2010 02:48:34 +0000</pubDate>
		<dc:creator>Chris Peters</dc:creator>
				<category><![CDATA[Administrivia]]></category>
		<category><![CDATA[ColdFusion]]></category>
		<category><![CDATA[adobe]]></category>
		<category><![CDATA[ccm]]></category>
		<category><![CDATA[cfml]]></category>
		<category><![CDATA[cfscript]]></category>
		<category><![CDATA[chris peters]]></category>
		<category><![CDATA[clear crystal media]]></category>
		<category><![CDATA[oop]]></category>
		<category><![CDATA[polymorphism]]></category>
		<category><![CDATA[railo]]></category>

		<guid isPermaLink="false">http://www.clearcrystalmedia.com/pm/?p=459</guid>
		<description><![CDATA[<p>A few months ago, I blogged about my excitement about the role that <a title="Script-based controllers and models, tag-based views" href="http://www.clearcrystalmedia.com/pm/script-controllers-models-tag-views/">full script <abbr title="ColdFusion Component">CFC</abbr>s could have in an <abbr title="Model-View-Controller">MVC</abbr> stack</a>, particularly with ColdFusion on Wheels. In my excitement to try out the new feature, I had spent much of a Saturday manually converting all of my components into CFScript components in my portal project called <a href="http://github.com/clearcrystalmedia/Administrivia">Administrivia</a>.</p>
<p>Unfortunately, the CFScript part of ColdFusion isn't quite where it needs to be yet. Read on to find out why.</p>]]></description>
			<content:encoded><![CDATA[<p>A few months ago, I blogged about my excitement about the role that <a title="Script-based controllers and models, tag-based views" href="http://www.clearcrystalmedia.com/pm/script-controllers-models-tag-views/">full script <abbr title="ColdFusion Component">CFC</abbr>s could have in an <abbr title="Model-View-Controller">MVC</abbr> stack</a>, particularly with ColdFusion on Wheels. In my excitement to try out the new feature, I had spent much of a Saturday manually converting all of my components into CFScript components in my portal project called <a href="http://github.com/clearcrystalmedia/Administrivia">Administrivia</a>.</p>
<p>Unfortunately, the CFScript part of ColdFusion isn&#8217;t quite where it needs to be yet.</p>
<p>Don&#8217;t get me wrong: CFScript is <em>much</em> improved over where it was in previous versions of ColdFusion. And I don&#8217;t get angry when I experiment with a feature and it doesn&#8217;t work out, but I also try my hardest to know when to back off and undo any damage before it goes <em>too far</em>.</p>
<h2>What didn&#8217;t work</h2>
<p>As it turns out, doing custom database queries in CFScript is very cumbersome. It starts feeling a little too much like <abbr title="PHP Hypertext Preprocessor">PHP</abbr>. Maybe even worse!</p>
<p>Consider this beautiful, expressive simplicity that we all love about <abbr title="ColdFusion Markup Language">CFML</abbr>:</p>

<div class="wp_syntax"><div class="code"><pre class="cfm" style="font-family:monospace;"><span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfquery</span> <span style="color: #0000FF;">datasource</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;#get('dataSourceName')#&quot;</span> <span style="color: #0000FF;">name</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;local.apps&quot;</span><span style="color: #0000FF;">&gt;</span></span>
    SELECT DISTINCT
        A.*
    FROM
        apps A
        JOIN appgroupmemberships G
            ON A.id = G.appid
    WHERE
        G.usergroupid IN (<span style="color: #0000FF;">#local.groupIds#</span>)
        AND deletedat IS NULL
<span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cfquery</span><span style="color: #0000FF;">&gt;</span></span></pre></div></div>

<p>And replace it with this garbage:</p>

<div class="wp_syntax"><div class="code"><pre class="cfm" style="font-family:monospace;">local.queryService = new Query(datasource=get('dataSourceName'));
local.queryService.setSql(&quot;
    SELECT DISTINCT
        A.*
    FROM
        apps A
        JOIN appgroupmemberships G
            ON A.id = G.appid
        WHERE
            G.usergroupid IN (<span style="color: #0000FF;">#local.groupIds#</span>)
            AND deletedat IS NULL
&quot;);
local.apps = local.queryService.Execute().GetResult();</pre></div></div>

<p>The last line is the part that really gets me. What is this, Java?</p>
<p>Also, it gets much worse when you need to cut in and out of the <abbr title="Structured Query Language">SQL</abbr> string that you&#8217;re building in order to add in <code>if</code> logic, loops, calls to <code>AddParam()</code>, etc.</p>
<p>The other big annoyance to me is CFScript&#8217;s lack of coverage for many of the other data communication tags. It hurts to not have equal functionality available for <code>cffeed</code>, <code>cfldap</code>, etc. I need to call more than just databases in my models and controllers.</p>
<h2>Realization: I need to support Railo too</h2>
<p>I need to work on adding support for <a href="http://www.getrailo.org/">Railo</a>, which <a href="http://railo.uservoice.com/forums/21016-general/suggestions/230165-full-cfscript-support?ref=title">doesn&#8217;t yet support full script-based components anyway</a>. So it was probably in my best interest to take some time to convert my components back to <abbr title="ColdFusion Markup Language">CFML</abbr> again.</p>
<p>Perhaps our paths shall cross again some day, CFScript. Until then, I bid you adieu.</p>

<!-- start wp-tags-to-technorati 1.01 -->

<p class='technorati-tags'>Technorati Tags: <a class='technorati-link' href='http://technorati.com/tag/adobe' rel='tag' target='_self'>adobe</a>, <a class='technorati-link' href='http://technorati.com/tag/ccm' rel='tag' target='_self'>ccm</a>, <a class='technorati-link' href='http://technorati.com/tag/cfml' rel='tag' target='_self'>cfml</a>, <a class='technorati-link' href='http://technorati.com/tag/cfscript' rel='tag' target='_self'>cfscript</a>, <a class='technorati-link' href='http://technorati.com/tag/chris+peters' rel='tag' target='_self'>chris peters</a>, <a class='technorati-link' href='http://technorati.com/tag/clear+crystal+media' rel='tag' target='_self'>clear crystal media</a>, <a class='technorati-link' href='http://technorati.com/tag/ColdFusion' rel='tag' target='_self'>ColdFusion</a>, <a class='technorati-link' href='http://technorati.com/tag/oop' rel='tag' target='_self'>oop</a>, <a class='technorati-link' href='http://technorati.com/tag/polymorphism' rel='tag' target='_self'>polymorphism</a>, <a class='technorati-link' href='http://technorati.com/tag/railo' rel='tag' target='_self'>railo</a></p>

<!-- end wp-tags-to-technorati -->
]]></content:encoded>
			<wfw:commentRss>http://www.clearcrystalmedia.com/pm/full-cfscript-cfcs-not-where-they-need-to-be/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
	</channel>
</rss>

