<?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>Dan's Drivelings &#187; Transfer ORM</title>
	<atom:link href="http://dan.skaggsfamily.ws/category/transfer-orm/feed/" rel="self" type="application/rss+xml" />
	<link>http://dan.skaggsfamily.ws</link>
	<description>Random Thoughts of a Techno-Hermit</description>
	<lastBuildDate>Thu, 09 Sep 2010 02:37:19 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Using Decorator objects in Transfer ORM</title>
		<link>http://dan.skaggsfamily.ws/2009/01/11/using-decorator-objects-in-transfer-orm/</link>
		<comments>http://dan.skaggsfamily.ws/2009/01/11/using-decorator-objects-in-transfer-orm/#comments</comments>
		<pubDate>Sun, 11 Jan 2009 22:53:43 +0000</pubDate>
		<dc:creator>Dan Skaggs</dc:creator>
				<category><![CDATA[ColdFusion]]></category>
		<category><![CDATA[Transfer ORM]]></category>

		<guid isPermaLink="false">http://dan.skaggsfamily.ws/?p=132</guid>
		<description><![CDATA[For the last few weeks I&#8217;ve been working on a project that uses the Mach II, ColdSpring and Transfer frameworks for ColdFusion. This is my first &#8220;real&#8221; project using Transfer and, I have to say, I&#8217;m supremely impressed with the thought and work put into the framework by Mark Mandel. It seems every time that [...]]]></description>
			<content:encoded><![CDATA[<p>For the last few weeks I&#8217;ve been working on a project that uses the Mach II, ColdSpring and Transfer frameworks for ColdFusion.  This is my first &#8220;real&#8221; project using Transfer and, I have to say, I&#8217;m supremely impressed with the thought and work put into the framework by Mark Mandel.  It seems every time that I come up with a question of how to do something, a quick look at the methods provided in the objects generated by Transfer reveals the answer.</p>
<p>The latest example came this week as we were moving more heavily into coding from the planning stages we&#8217;d been in for the most part up to now when I had an occasion to use the decorator feature built into Transfer.</p>
<p><span id="more-132"></span>If you&#8217;ve done any object-oriented development you&#8217;re familiar with the concept of building methods inside your objects to contain calculations or logic specific to that particular object. That&#8217;s easy enough to do when you are writing your own bean objects, but becomes somewhat of a problem when your bean objects are auto generated by Transfer. This is the exact situation that decorators are designed to solve. The decorator pattern &#8220;allows new/additional behaviour to be added to an existing class dynamically&#8221; (<a href="http://en.wikipedia.org/wiki/Decorator_pattern" target="_blank">Wikipedia</a>).</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;object</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;Product&quot;</span> <span style="color: #000066;">table</span>=<span style="color: #ff0000;">&quot;products&quot;</span> </span>
<span style="color: #009900;">    <span style="color: #000066;">decorator</span>=<span style="color: #ff0000;">&quot;components.decorators.ProductDecorator&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;id</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;productID&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;numeric&quot;</span> <span style="color: #000066;">generate</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #808080; font-style: italic;">&lt;!-- more properties --&gt;</span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/object<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Using the code above, we can create a ProductDecorator.cfc in the /components/decorators folder and put any custom properties and methods that we need for the Product bean there.  The really sweet part is that, when Transfer instantiates a Product object, it automatically merges any properties and methods that you create in the ProductDecorator into the generated object.  So, you as the developer don&#8217;t have to do anything extra in order to access your custom methods than you would if you were accessing the methods generated by Transfer.  Simply get your object as normal (via the new(), read(), getByProperty() methods etc) and the resulting object returned to you will have your methods and properties included as well.</p>
<p>Simple, elegant, and really slick.</p>
]]></content:encoded>
			<wfw:commentRss>http://dan.skaggsfamily.ws/2009/01/11/using-decorator-objects-in-transfer-orm/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
