<?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>Pathfinder Software &#187; Anthony Caliendo</title>
	<atom:link href="http://pathfindersoftware.com/author/anthony-caliendo/feed/" rel="self" type="application/rss+xml" />
	<link>http://pathfindersoftware.com</link>
	<description>The Fastest Way to Launch Successful Software</description>
	<lastBuildDate>Thu, 19 Jan 2012 16:31:04 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Accessing the Icon for a Button Programmatically in Flex 3</title>
		<link>http://pathfindersoftware.com/2009/09/accessing_the_icon_for_a_button_programmatically_in_flex_3/</link>
		<comments>http://pathfindersoftware.com/2009/09/accessing_the_icon_for_a_button_programmatically_in_flex_3/#comments</comments>
		<pubDate>Wed, 16 Sep 2009 17:01:12 +0000</pubDate>
		<dc:creator>Anthony Caliendo</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[Rich Internet Apps]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[flex 3]]></category>

		<guid isPermaLink="false">http://www.pathf.com/blogs/?p=4024</guid>
		<description><![CDATA[The other day, I was trying to get the icon for a button in flex programmatically for a FlexUnit test. The code I was testing set the icon of a button using setStyle('icon', ICON). I attempted the obvious button.getStyle('icon') in the test, but was surprised that this always returned null. A little bit of digging ...]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F09%2Faccessing_the_icon_for_a_button_programmatically_in_flex_3%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F09%2Faccessing_the_icon_for_a_button_programmatically_in_flex_3%2F&amp;source=PathSoft&amp;style=normal&amp;service=bit.ly&amp;service_api=R_8a1154b608af9e55718b231fb0025d40&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<div class="right">
<img src="http://pathfindersoftware.com/wp-content/uploads/flex_logo1.png" alt="flex_logo" title="flex_logo" width="128" height="121" class="alignnone size-full wp-image-4026" />
</div>
<p>The other day, I was trying to get the icon for a button in flex programmatically for a FlexUnit test.   The code I was testing set the icon of a button using <code>setStyle('icon', ICON)</code>.  I attempted the obvious <code>button.getStyle('icon')</code> in the test, but was surprised that this always returned <code>null</code>.</p>
<p>A little bit of digging revealed that the I needed to go through the style declaration for the button.  When changing my test to assert on <strong><code>button.styleDeclaration.getStyle('icon')</code></strong>, I was able to successfully access the icon.</p>
<p>I found this a bit non-intuitive, but fortunately it only involved some investigation and minimal code changes.
<p><a class="a2a_button_linkedin" href="http://www.addtoany.com/add_to/linkedin?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F09%2Faccessing_the_icon_for_a_button_programmatically_in_flex_3%2F&amp;linkname=Accessing%20the%20Icon%20for%20a%20Button%20Programmatically%20in%20Flex%203" title="LinkedIn" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/linkedin.png" width="16" height="16" alt="LinkedIn"/></a><a class="a2a_button_stumbleupon" href="http://www.addtoany.com/add_to/stumbleupon?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F09%2Faccessing_the_icon_for_a_button_programmatically_in_flex_3%2F&amp;linkname=Accessing%20the%20Icon%20for%20a%20Button%20Programmatically%20in%20Flex%203" title="StumbleUpon" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/stumbleupon.png" width="16" height="16" alt="StumbleUpon"/></a><a class="a2a_button_digg" href="http://www.addtoany.com/add_to/digg?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F09%2Faccessing_the_icon_for_a_button_programmatically_in_flex_3%2F&amp;linkname=Accessing%20the%20Icon%20for%20a%20Button%20Programmatically%20in%20Flex%203" title="Digg" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/digg.png" width="16" height="16" alt="Digg"/></a><a class="a2a_button_dzone" href="http://www.addtoany.com/add_to/dzone?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F09%2Faccessing_the_icon_for_a_button_programmatically_in_flex_3%2F&amp;linkname=Accessing%20the%20Icon%20for%20a%20Button%20Programmatically%20in%20Flex%203" title="DZone" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/dzone.png" width="16" height="16" alt="DZone"/></a><a class="a2a_button_reddit" href="http://www.addtoany.com/add_to/reddit?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F09%2Faccessing_the_icon_for_a_button_programmatically_in_flex_3%2F&amp;linkname=Accessing%20the%20Icon%20for%20a%20Button%20Programmatically%20in%20Flex%203" title="Reddit" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/reddit.png" width="16" height="16" alt="Reddit"/></a><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F09%2Faccessing_the_icon_for_a_button_programmatically_in_flex_3%2F&amp;linkname=Accessing%20the%20Icon%20for%20a%20Button%20Programmatically%20in%20Flex%203" title="Delicious" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_button_evernote" href="http://www.addtoany.com/add_to/evernote?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F09%2Faccessing_the_icon_for_a_button_programmatically_in_flex_3%2F&amp;linkname=Accessing%20the%20Icon%20for%20a%20Button%20Programmatically%20in%20Flex%203" title="Evernote" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/evernote.png" width="16" height="16" alt="Evernote"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F09%2Faccessing_the_icon_for_a_button_programmatically_in_flex_3%2F&amp;title=Accessing%20the%20Icon%20for%20a%20Button%20Programmatically%20in%20Flex%203" id="wpa2a_2">Share/Bookmark</a></p>
]]></content:encoded>
			<wfw:commentRss>http://pathfindersoftware.com/2009/09/accessing_the_icon_for_a_button_programmatically_in_flex_3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>acts_without_database: Now a Rails Plugin</title>
		<link>http://pathfindersoftware.com/2009/09/actswithoutdatabase-rails-plugin/</link>
		<comments>http://pathfindersoftware.com/2009/09/actswithoutdatabase-rails-plugin/#comments</comments>
		<pubDate>Wed, 02 Sep 2009 16:49:08 +0000</pubDate>
		<dc:creator>Anthony Caliendo</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Technologies and Platforms]]></category>
		<category><![CDATA[activerecord]]></category>
		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://www.pathf.com/blogs/?p=3886</guid>
		<description><![CDATA[Quite a while ago, I wrote a blog post which included some code which allowed you to use ActiveRecord without needing a database table. I recently needed that functionality again, so I converted that code into a plugin and put it on github so that I could easily include it in another project. While doing ...]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F09%2Factswithoutdatabase-rails-plugin%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F09%2Factswithoutdatabase-rails-plugin%2F&amp;source=PathSoft&amp;style=normal&amp;service=bit.ly&amp;service_api=R_8a1154b608af9e55718b231fb0025d40&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<div class="right"><img src="http://pathfindersoftware.com/wp-content/uploads/rails5.png" alt="Ruby on Rails" title="Ruby on Rails" width="50" height="64" class="alignnone size-full wp-image-1100" /></div>
<p>Quite a while ago, I wrote a <a href="http://www.pathf.com/blogs/2008/12/acts_without_database-using-activerecord-for-non-database-backed-objects/">blog post</a> which included some code which allowed you to use ActiveRecord without needing a database table.</p>
<p>I recently needed that functionality again, so I converted that code into a plugin and put it on github so that I could easily include it in another project.  While doing this, I also cleaned up and simplified the code quite a bit.</p>
<p>The github page is here: <a href="http://github.com/AnthonyCaliendo/acts_without_database/">http://github.com/AnthonyCaliendo/acts_without_database/</a></p>
<p>Related Services:  <a href="http://www.pathf.com/services/technology-expertise/ruby-on-rails/">Ruby on Rails Development</a><br />
, <a href="http://www.pathf.com/services">Custom Software Development</a>
<p><a class="a2a_button_linkedin" href="http://www.addtoany.com/add_to/linkedin?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F09%2Factswithoutdatabase-rails-plugin%2F&amp;linkname=acts_without_database%3A%20Now%20a%20Rails%20Plugin" title="LinkedIn" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/linkedin.png" width="16" height="16" alt="LinkedIn"/></a><a class="a2a_button_stumbleupon" href="http://www.addtoany.com/add_to/stumbleupon?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F09%2Factswithoutdatabase-rails-plugin%2F&amp;linkname=acts_without_database%3A%20Now%20a%20Rails%20Plugin" title="StumbleUpon" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/stumbleupon.png" width="16" height="16" alt="StumbleUpon"/></a><a class="a2a_button_digg" href="http://www.addtoany.com/add_to/digg?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F09%2Factswithoutdatabase-rails-plugin%2F&amp;linkname=acts_without_database%3A%20Now%20a%20Rails%20Plugin" title="Digg" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/digg.png" width="16" height="16" alt="Digg"/></a><a class="a2a_button_dzone" href="http://www.addtoany.com/add_to/dzone?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F09%2Factswithoutdatabase-rails-plugin%2F&amp;linkname=acts_without_database%3A%20Now%20a%20Rails%20Plugin" title="DZone" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/dzone.png" width="16" height="16" alt="DZone"/></a><a class="a2a_button_reddit" href="http://www.addtoany.com/add_to/reddit?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F09%2Factswithoutdatabase-rails-plugin%2F&amp;linkname=acts_without_database%3A%20Now%20a%20Rails%20Plugin" title="Reddit" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/reddit.png" width="16" height="16" alt="Reddit"/></a><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F09%2Factswithoutdatabase-rails-plugin%2F&amp;linkname=acts_without_database%3A%20Now%20a%20Rails%20Plugin" title="Delicious" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_button_evernote" href="http://www.addtoany.com/add_to/evernote?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F09%2Factswithoutdatabase-rails-plugin%2F&amp;linkname=acts_without_database%3A%20Now%20a%20Rails%20Plugin" title="Evernote" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/evernote.png" width="16" height="16" alt="Evernote"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F09%2Factswithoutdatabase-rails-plugin%2F&amp;title=acts_without_database%3A%20Now%20a%20Rails%20Plugin" id="wpa2a_4">Share/Bookmark</a></p>
]]></content:encoded>
			<wfw:commentRss>http://pathfindersoftware.com/2009/09/actswithoutdatabase-rails-plugin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using Mocha for ActiveRecord Partial Mocks with Finders</title>
		<link>http://pathfindersoftware.com/2009/08/using-mocha-for-activerecord-partial-mocks-with-finders/</link>
		<comments>http://pathfindersoftware.com/2009/08/using-mocha-for-activerecord-partial-mocks-with-finders/#comments</comments>
		<pubDate>Wed, 26 Aug 2009 16:37:58 +0000</pubDate>
		<dc:creator>Anthony Caliendo</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Technologies and Platforms]]></category>
		<category><![CDATA[activerecord]]></category>
		<category><![CDATA[Mocha]]></category>
		<category><![CDATA[Mock]]></category>
		<category><![CDATA[mocking]]></category>
		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://www.pathf.com/blogs/?p=3756</guid>
		<description><![CDATA[Mocha on sparklette.net Mocha is the mocking library used by the Rails team, so it has understandably gained some traction among Rails developers. I have started using it over flexmock lately, but ran into some problems with partial mocks on ActiveRecord objects. The problem stemmed from the fact that ActiveRecord instantiates new records when returning ...]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F08%2Fusing-mocha-for-activerecord-partial-mocks-with-finders%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F08%2Fusing-mocha-for-activerecord-partial-mocks-with-finders%2F&amp;source=PathSoft&amp;style=normal&amp;service=bit.ly&amp;service_api=R_8a1154b608af9e55718b231fb0025d40&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<div class="right">
<img src="http://pathfindersoftware.com/wp-content/uploads/mocha1.jpg" alt="mocha" title="mocha" width="225" height="168" class="right" /><br />
<br clear="all"/><br />
<span class="right" style="font-size: smaller"><br />
<a href="http://pathfindersoftware.com/wp-content/uploads/mocha2.jpg">Mocha on sparklette.net</a><br />
</span>
</div>
<p><a href="http://github.com/floehopper/mocha/tree/master">Mocha</a> is the mocking library used by the Rails team, so it has understandably gained some traction among Rails developers.  I have started using it over <a href="http://github.com/jimweirich/flexmock/tree/master">flexmock</a> lately, but ran into some problems with partial mocks on ActiveRecord objects.  The problem stemmed from the fact that ActiveRecord instantiates new records when returning records from finders, which meant that creating partial mocks for a particular record was difficult.</p>
<p>I created a helper method to make this easier, and so far it has cleaned up a bit of my tests.<br />
<span id="more-3756"></span></p>
<p>Using <a href="http://mocha.rubyforge.org/classes/Mocha/ClassMethods.html#M000001">#<code>any_instance</code></a> is not helpful in the cases I ran into, since I wanted to target a specific record for different expectations.</p>
<p>You could mock out the individual #<code>find</code> or #<code>find_by_*</code> methods as needed in each test, but that didn&#8217;t seem ideal to me.  Instead, I dug a bit into ActiveRecord to find what method was called when it actually instantiated the records after a find.  I discovered that there is an #<code>instantiate</code> method which takes a hash of column=>value pairs from the finder to instantiate those records.</p>
<p>The following is the helper method which I created to do this:</p>
<pre lang="ruby">
def mock_active_records(*records)
    records.each do |record|
      record.class.stubs(:instantiate).with(
        has_entry('id', record.id.to_s)
      ).returns(record)
      record.stubs(:reload).returns(record)
    end
  end
</pre>
<p>Here is an example test:</p>
<pre lang="ruby">
require 'test_helper'
class UserTest < ActiveSupport::TestCase
  setup do
    @user = User.create!
    @non_pending_order = user.orders.create!
    @pending_order = user.orders.create! :pending => true
    mock_active_records @non_pending_order, @pending_order
  end

  test 'cancels pending orders when deactivating user' do
    @non_pending_order.expects(:cancel).never
    @pending_order.expects(:cancel).once

    @user.deactivate!
  end
end
</pre>
<p>This test makes sure that when I deactivate a user, that I call the cancel method on only the pending order.</p>
<p>Now, you may be asking &#8220;why don&#8217;t I just test the side effects of cancel on the orders?&#8221;  Well, I feel that what happens during cancel for an order is outside the scope of a unit test for user.  In this example, cancel can have a multitude of side effects.  In the context of a unit test for a user, I don&#8217;t care what happens when I cancel an order.  I only care that I do cancel it.<br />
Also, if cancel needed to make an outbound call to another system, I wouldn&#8217;t want an external system to be a dependency of my unit test.  Mocking out the method removes any external and implementation dependencies in my unit tests (a functional test is a different matter, mind you).</p>
<p>Related Services:  <a href="http://www.pathf.com/services/technology-expertise/ruby-on-rails/">Ruby on Rails Development</a>, <a href="http://www.pathf.com/services">Custom Software Development</a>
<p><a class="a2a_button_linkedin" href="http://www.addtoany.com/add_to/linkedin?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F08%2Fusing-mocha-for-activerecord-partial-mocks-with-finders%2F&amp;linkname=Using%20Mocha%20for%20ActiveRecord%20Partial%20Mocks%20with%20Finders" title="LinkedIn" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/linkedin.png" width="16" height="16" alt="LinkedIn"/></a><a class="a2a_button_stumbleupon" href="http://www.addtoany.com/add_to/stumbleupon?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F08%2Fusing-mocha-for-activerecord-partial-mocks-with-finders%2F&amp;linkname=Using%20Mocha%20for%20ActiveRecord%20Partial%20Mocks%20with%20Finders" title="StumbleUpon" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/stumbleupon.png" width="16" height="16" alt="StumbleUpon"/></a><a class="a2a_button_digg" href="http://www.addtoany.com/add_to/digg?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F08%2Fusing-mocha-for-activerecord-partial-mocks-with-finders%2F&amp;linkname=Using%20Mocha%20for%20ActiveRecord%20Partial%20Mocks%20with%20Finders" title="Digg" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/digg.png" width="16" height="16" alt="Digg"/></a><a class="a2a_button_dzone" href="http://www.addtoany.com/add_to/dzone?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F08%2Fusing-mocha-for-activerecord-partial-mocks-with-finders%2F&amp;linkname=Using%20Mocha%20for%20ActiveRecord%20Partial%20Mocks%20with%20Finders" title="DZone" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/dzone.png" width="16" height="16" alt="DZone"/></a><a class="a2a_button_reddit" href="http://www.addtoany.com/add_to/reddit?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F08%2Fusing-mocha-for-activerecord-partial-mocks-with-finders%2F&amp;linkname=Using%20Mocha%20for%20ActiveRecord%20Partial%20Mocks%20with%20Finders" title="Reddit" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/reddit.png" width="16" height="16" alt="Reddit"/></a><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F08%2Fusing-mocha-for-activerecord-partial-mocks-with-finders%2F&amp;linkname=Using%20Mocha%20for%20ActiveRecord%20Partial%20Mocks%20with%20Finders" title="Delicious" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_button_evernote" href="http://www.addtoany.com/add_to/evernote?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F08%2Fusing-mocha-for-activerecord-partial-mocks-with-finders%2F&amp;linkname=Using%20Mocha%20for%20ActiveRecord%20Partial%20Mocks%20with%20Finders" title="Evernote" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/evernote.png" width="16" height="16" alt="Evernote"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F08%2Fusing-mocha-for-activerecord-partial-mocks-with-finders%2F&amp;title=Using%20Mocha%20for%20ActiveRecord%20Partial%20Mocks%20with%20Finders" id="wpa2a_6">Share/Bookmark</a></p>
]]></content:encoded>
			<wfw:commentRss>http://pathfindersoftware.com/2009/08/using-mocha-for-activerecord-partial-mocks-with-finders/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>3 Misuses of Code Comments</title>
		<link>http://pathfindersoftware.com/2009/07/3-misuses-of-code-comments/</link>
		<comments>http://pathfindersoftware.com/2009/07/3-misuses-of-code-comments/#comments</comments>
		<pubDate>Wed, 01 Jul 2009 13:44:48 +0000</pubDate>
		<dc:creator>Anthony Caliendo</dc:creator>
				<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Code Style]]></category>
		<category><![CDATA[Maintainability]]></category>
		<category><![CDATA[Software Development Best Practices]]></category>
		<category><![CDATA[Software Maintenance]]></category>

		<guid isPermaLink="false">http://www.pathf.com/blogs/?p=3118</guid>
		<description><![CDATA[Photo Credit: by dpascoe Not many people talk about good practices to use for comments in code. Many people see them as an extra or freebie, so not a lot of thought gets put into them. The truth is, though, that comments are a great tool for giving insight into the thought process when the ...]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F07%2F3-misuses-of-code-comments%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F07%2F3-misuses-of-code-comments%2F&amp;source=PathSoft&amp;style=normal&amp;service=bit.ly&amp;service_api=R_8a1154b608af9e55718b231fb0025d40&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<div class="right">
<img src="http://pathfindersoftware.com/wp-content/uploads/hammer-and-screw1.jpg" alt="hammer-and-screw" title="hammer-and-screw" width="162" height="120" class="alignnone size-full wp-image-3119" /><br />
<small>Photo Credit: by <a title="Attribution License" href="http://pathfindersoftware.com/wp-content/uploads/hammer-and-screw2.jpg" target="_blank">dpascoe</a></small>
</div>
<p>Not many people talk about good practices to use for comments in code.  Many people see them as an extra or freebie, so not a lot of thought gets put into them.  The truth is, though, that comments are a great tool for giving insight into the thought process when the code was being written.  Unfortunately like any tool, comments can be misused.</p>
<p>Here are three of the most common misuses of comments which I tend to run into.</p>
<p><span id="more-3118"></span></p>
<p><strong>1. Commenting the Obvious</strong><br />
<em>A.K.A. Superfluous Comments</em><br />
A good rule of thumb for comments is to not comment on what the code is doing, but <u>why</u> it is doing it.  You then try to write the code as self-documenting as possible so that footnotes aren&#8217;t required to figure out what is going on.  Obviously, there are going to be some times when this rule can&#8217;t be followed because of the complexity of the situation and in those cases comments about what is going on is valuable.  However, you will sometimes run into comments for code which is easy to understand</p>
<p>Please take a look at the following real live example from some Flex 3 SDK code which sparked the idea for this post.  I would have to assume that anyone familiar with ActionScript would be able to figure it out on their own&#8230;<br />
<strong>BAD</strong></p>
<pre lang="actionscript">
    //--------------------------------------------------------------------------
    //
    //  Constructor
    //
    //--------------------------------------------------------------------------

    /**
     *  Constructor.
     */
    public function TextInput()
    {
        super();

        // InteractiveObject variables.
        tabChildren = true;
    }
</pre>
<p>When I saw that first giant comment, I thought to myself &#8220;hey, this just <em>might</em> be a constructor&#8221;.  When I saw the second comment, I was sold on the idea!  Nestle that third comment about <code>InteractiveObject</code> variables into your mind for the next misuse (misleading comments), but try to focus on the first two for this one.</p>
<p>Commenting on very obvious stuff such as &#8220;this is a constructor&#8221; just creates clutter which reduces the readability of the code.  Instead of seeing more code at once, I have to scroll past large chunks of useless information.  Whatever &#8220;code style&#8221; reasons people use as rationalization, these types of comments are unnecessary and don&#8217;t provide useful additional information or clarity (the whole point of comments).   If you feel you need a map to show where things are located, I would suggest refactoring into smaller classes and/or establishing code formatting guidelines (such as, &#8220;static variables go at the top above the constructor&#8221;).</p>
<p>So, knowing this, what should the comments look like?<br />
<strong>BETTER</strong></p>
<pre lang="actionscript">
    public function TextInput()
    {
        super();

        // We want our children to be tab-enabled since our TextField
        // child will be handling a lot of the work, so force this
        // value to true to allow that.
        tabChildren = true;
    }
</pre>
<p>Now, my attention is focused on a useful comment and not parsing through a lot of useless comments.</p>
<p><strong>2. Comment Confusion</strong><br />
<em>A.K.A. Incorrect or Misleading Comments</em><br />
There are two main causes for this problem.  The first cause is if the coder will write a comment that is either incorrect or not very obvious.  Sometimes this is because the confusing comment makes sense to the person writing it, and sometimes it is just because the person made a mistake.  The second cause is &#8220;code/comment drift&#8221;; this is when code is updated but the comments are not.  Code can change over time, but sometimes the comments that explain what is going on are left behind when the code changes to do something else.</p>
<p>Whatever the cause, incorrect or misleading comments can lead to confusion when the comment contradicts the code in subtle (or not so subtle) ways; you have to dig through source control or old requirements (which are sometimes not updated either) to figure out what the code should be doing.  It is an even worse problem if there is no test for the logic in question.</p>
<p>Deleting or updating comments when you change the code seems obvious to most, but I have run into this problem on more than one occasion.  The same goes for writing clear comments.  I could have used the previous example&#8217;s comment  of &#8220;<code>// InteractiveObject variables.</code>&#8221; to illustrate this point since that is confusing given what the code which follows it actually does , but I&#8217;m going to spoil you with an exaggerated fake example.<br />
<strong>BAD</strong></p>
<pre lang="java">
public int count(List<something> stuff) {
    // the number of foos we find
    int barTotal = 0;

    // count foos
    for (Something it : stuff) {
        if (it.isBar()) {
            barTotal += 1;
        }
    }

    // return foo count
    return barTotal;
}
</pre>
<p>Now, judging by the comments, the code has a bug since it should be counting foos and not bars.  In a perfect world, the method would be named better to indicate what needs to be counted (self-documenting code) and there would be a unit test which would prove what should be going on.  But since we don&#8217;t have any of that, we are left scratching our heads and spending time looking in source control and old requirements documents to try to figure out what needs to be counted.</p>
<p>What would some better comments look like? (N.B. I won&#8217;t change any of the code&#8217;s naming, which is really what needs to be done in this case).<br />
<strong>BETTER</strong></p>
<pre lang="java">
/**
  * Count the number of bars in the passed list, and return it
  */
public int count(List<something> stuff) {
    int barTotal = 0;

    for (Something it : stuff) {
        if (it.isBar()) {
            barTotal += 1;
        }
    }

    return barTotal;
}
</pre>
<p>Notice that I made the comment reflect the code.  In the absence of any evidence of what the code should be doing, assume that it is doing the right thing and adjust the comments to reflect that.  This piece of code still needs to be investigated to determine if it is a bug or not (no, seriously, just changing comments is sweeping the problem under the rug), but at least the comment confusion has been removed.</p>
<p><strong>3. Not Enough Comments</strong><br />
<em>A.K.A. Failure to Execute</em><br />
This is probably the most common situation.  When writing code, people don&#8217;t tend to think about maintaining the code or they have difficultly realizing what &#8220;unique knowledge&#8221; they have about the situation which makes certain things obvious to them but completely confusing to someone else.</p>
<p>Knowing when a comment is needed is an art and it is difficult to give direction.  The one piece of advice which I&#8217;ve found useful is to ask yourself the question &#8220;if I came back and looked at this code in a year, would I know what is going on?&#8221;.  If not, try to leave comments which would help your future self figure that out.</p>
<p>Take a look at the following:<br />
<strong>BAD</strong></p>
<pre lang="java">
public void handleError(int errorCode) {
    if (errorCode < 3) {
        errorCode += 1;
    }

    notify("received error" + errorCode);
}
</pre>
<p>Now, why exactly do we need to add one if the error code is less than three?  What sort of madness is behind this?</p>
<p>Without a comment to tell someone what is going on (or remind yourself), this magic math is a mystery.  Do we need to do this?  Has the reason for this apparent hack changed since it was coded up?  Keep in mind that a unit test wouldn't be much help here unless it had comments or a name which implied why this is being done.</p>
<p>Now, let's take a look at the same code which different comments.<br />
<strong>BETTER</strong></p>
<pre lang="java">
public void handleError(int errorCode) {
    // to support operations, our error codes need to be translated
    // to their scheme.  the mapping is:
    //     our 3 and up = the same for operations
    //     our 0 = their 1
    //     our 1 = their 2
    //     our 2 = their 3
    if (errorCode < 3) {
        errorCode += 1;
    }

    notify("received error" + errorCode);
}
</pre>
<p>With just a simple comment, the reasoning for this math is now known to anyone who looks at the code.  A year later, you will be able to look at the code and know why that math is being done.<br />
<strong><em>UPDATE: 3:30PM CT</em></strong>: Again, the correct solution to this problem would be to refactor the code to be self-documenting; however, I wanted to focus mainly on the comment aspect of this instead of improving the code itself.  Improving the code would make the comment completely unnecessary, but ignore that for the sake of this example <img src='http://pathfindersoftware.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
<p>Good coding practices, TDD, and pair programming will play a major role in alleviating comment misuse.  However, keeping in mind the rule of commenting the <em>why</em> and not the <em>what</em> will go a long way to improving comment quality.
<p><a class="a2a_button_linkedin" href="http://www.addtoany.com/add_to/linkedin?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F07%2F3-misuses-of-code-comments%2F&amp;linkname=3%20Misuses%20of%20Code%20Comments" title="LinkedIn" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/linkedin.png" width="16" height="16" alt="LinkedIn"/></a><a class="a2a_button_stumbleupon" href="http://www.addtoany.com/add_to/stumbleupon?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F07%2F3-misuses-of-code-comments%2F&amp;linkname=3%20Misuses%20of%20Code%20Comments" title="StumbleUpon" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/stumbleupon.png" width="16" height="16" alt="StumbleUpon"/></a><a class="a2a_button_digg" href="http://www.addtoany.com/add_to/digg?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F07%2F3-misuses-of-code-comments%2F&amp;linkname=3%20Misuses%20of%20Code%20Comments" title="Digg" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/digg.png" width="16" height="16" alt="Digg"/></a><a class="a2a_button_dzone" href="http://www.addtoany.com/add_to/dzone?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F07%2F3-misuses-of-code-comments%2F&amp;linkname=3%20Misuses%20of%20Code%20Comments" title="DZone" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/dzone.png" width="16" height="16" alt="DZone"/></a><a class="a2a_button_reddit" href="http://www.addtoany.com/add_to/reddit?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F07%2F3-misuses-of-code-comments%2F&amp;linkname=3%20Misuses%20of%20Code%20Comments" title="Reddit" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/reddit.png" width="16" height="16" alt="Reddit"/></a><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F07%2F3-misuses-of-code-comments%2F&amp;linkname=3%20Misuses%20of%20Code%20Comments" title="Delicious" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_button_evernote" href="http://www.addtoany.com/add_to/evernote?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F07%2F3-misuses-of-code-comments%2F&amp;linkname=3%20Misuses%20of%20Code%20Comments" title="Evernote" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/evernote.png" width="16" height="16" alt="Evernote"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F07%2F3-misuses-of-code-comments%2F&amp;title=3%20Misuses%20of%20Code%20Comments" id="wpa2a_8">Share/Bookmark</a></p>
]]></content:encoded>
			<wfw:commentRss>http://pathfindersoftware.com/2009/07/3-misuses-of-code-comments/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Grails: Custom Parent/Child Aware Tags</title>
		<link>http://pathfindersoftware.com/2009/06/grails-custom-parent-child-aware-tags/</link>
		<comments>http://pathfindersoftware.com/2009/06/grails-custom-parent-child-aware-tags/#comments</comments>
		<pubDate>Wed, 03 Jun 2009 12:56:55 +0000</pubDate>
		<dc:creator>Anthony Caliendo</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Technologies and Platforms]]></category>
		<category><![CDATA[Grails]]></category>
		<category><![CDATA[tag]]></category>
		<category><![CDATA[taglib]]></category>

		<guid isPermaLink="false">http://www.pathf.com/blogs/?p=2610</guid>
		<description><![CDATA[Recently, I needed to create a special tag in Grails which would render specific children in a way that is aware of their order. I wanted to stick entirely with markup (not passing an array to a tag), and also wanted to avoid putting lots of logic inside a .tag file. While it was possible ...]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F06%2Fgrails-custom-parent-child-aware-tags%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F06%2Fgrails-custom-parent-child-aware-tags%2F&amp;source=PathSoft&amp;style=normal&amp;service=bit.ly&amp;service_api=R_8a1154b608af9e55718b231fb0025d40&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<div class="right"><img src="http://pathfindersoftware.com/wp-content/uploads/grails_logo2.png" alt="grails_logo" title="grails_logo" width="196" height="53" class="alignnone size-full wp-image-1393" /></div>
<p>Recently, I needed to create a special tag in Grails which would render specific children in a way that is aware of their order.  I wanted to stick entirely with markup (not passing an array to a tag), and also wanted to avoid putting lots of logic inside a <em>.tag</em> file.  While it was possible to write a tag lib which first parsed the children in a &#8220;non-render&#8221; mode, I preferred a solution which did not require doing my own parsing before render.  The solution I came up with isn&#8217;t the most flexible, but it got the job done in a relatively clean way with minimal custom code.</p>
<p>The following is an example solution with the associated code and tests.<br />
<span id="more-2610"></span><br />
The problem is this: I want a parent tag which will add different class names to the children depending on their order.  For this example, we will be adding even/odd and a first/last class to the appropriate children.  For the purposes of this example, we will ignore <a href="http://www.w3.org/TR/css3-selectors/">CSS 3.0 Selectors</a>, which could do this entirely in the stylesheet.</p>
<p>First, let&#8217;s generate our tag lib through grails.</p>
<pre>
grails create-tag-lib ParentChild
</pre>
<p>Now that we have our empty files, we can write a test to define the expected behavior in the generated test file.  Make sure that you are extending <em>grails.test.GroovyPagesTestCase</em>.</p>
<pre lang="groovy">
class ParentChildTagLibTests extends grails.test.GroovyPagesTestCase {

    void testParentContainerShouldRenderChildren() {
        def writer = new StringWriter()
        def markup = new groovy.xml.MarkupBuilder(writer)
        markup {
            ul('class':'myParent') {
                li('class':'myChild even first') {
                    a(href:'/first', 'one')
                }
                li('class':'myChild odd') {
                    a(href:'/second', 'two')
                }
                li('class':'myChild even last') {
                    a(href:'/third', 'three')
                }
            }
        }

        assertOutputEquals(
            writer.toString(),
            '<example:parentContainer><example:child label="one" url="[controller: 'first']"/><example:child label="two" url="[controller: 'second']"/><example:child label="three" url="[controller: 'third']"/></example:parentContainer>'
        )
    }
}
</pre>
<p>Now that we have a failing test, we can write the actual code.  Notice that I used a custom namespace here (just for the sake of example).</p>
<pre lang="groovy">
class ParentChildTagLib {

    static namespace = 'example'

    def parentContainer = {attrs, body ->
          // we'll be using this to keep track of our children
          def children = []
          this.pageScope.parentContainerChildren = children
          // this will execute the body, so that the children are
          // appended.  obviously, anything other than child
          // tags will not render correctly.
          body()

          def mkp = new groovy.xml.MarkupBuilder(out)
          mkp {
              ul('class': 'myParent') {
                  // iterate over all the children, and
                  // render them here
                  children.eachWithIndex {child, index ->
                      li('class': determineClassNames(child, children, index)) {
                          a(href: g.createLink(child.url), child.label)
                      }
                  }
              }
          }
      }

      private def determineClassNames(child, children, index) {
          def classNames = 'myChild'

          if (index % 2 == 0) {
              classNames += ' even'
          } else {
              classNames += ' odd'
          }

          if (child == children.first()) {
              classNames += ' first'
          } else if (child == children.last()) {
              classNames += ' last'
          }

          return classNames
      }

      def child = {attrs, body ->
          // simply keep track of the tag attributes
          this.pageScope.parentContainerChildren << attrs
      }
}
</pre>
<p>Now, given the following GSP code:</p>
<pre lang="xml">
<example:parentContainer>
    <example:child label="one" url="[controller: 'first']"/>
    <example:child label="two" url="[controller: 'second']"/>
    <example:child label="three" url="[controller: 'third']"/>
</example:parentContainer>
</pre>
<p>I get the following HTML generated:</p>
<pre lang="xml">
<ul class='myParent'>
<li class='myChild even first'>
    <a href='/first'>one</a>
  </li>
<li class='myChild odd'>
    <a href='/second'>two</a>
  </li>
<li class='myChild even last'>
    <a href='/third'>three</a>
  </li>
</ul>
</pre>
<p>There are some limitations to this strategy.  First, any other markup outside of the child tag inside the parent is not going to render how you'd expect.  Also, nested parent tags aren't going to work for this implementation unless you make some changes.  Finally, this implementation won't support body markup in the child tags; however, given a little tweaking it could be made to do that (I'll leave that as an exercise for the reader).</p>
<p>Despite these limitations, if you are looking to do something like breadcrumbs, tab navigation, or custom list rendering, then this may fit your needs.
<p><a class="a2a_button_linkedin" href="http://www.addtoany.com/add_to/linkedin?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F06%2Fgrails-custom-parent-child-aware-tags%2F&amp;linkname=Grails%3A%20Custom%20Parent%2FChild%20Aware%20Tags" title="LinkedIn" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/linkedin.png" width="16" height="16" alt="LinkedIn"/></a><a class="a2a_button_stumbleupon" href="http://www.addtoany.com/add_to/stumbleupon?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F06%2Fgrails-custom-parent-child-aware-tags%2F&amp;linkname=Grails%3A%20Custom%20Parent%2FChild%20Aware%20Tags" title="StumbleUpon" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/stumbleupon.png" width="16" height="16" alt="StumbleUpon"/></a><a class="a2a_button_digg" href="http://www.addtoany.com/add_to/digg?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F06%2Fgrails-custom-parent-child-aware-tags%2F&amp;linkname=Grails%3A%20Custom%20Parent%2FChild%20Aware%20Tags" title="Digg" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/digg.png" width="16" height="16" alt="Digg"/></a><a class="a2a_button_dzone" href="http://www.addtoany.com/add_to/dzone?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F06%2Fgrails-custom-parent-child-aware-tags%2F&amp;linkname=Grails%3A%20Custom%20Parent%2FChild%20Aware%20Tags" title="DZone" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/dzone.png" width="16" height="16" alt="DZone"/></a><a class="a2a_button_reddit" href="http://www.addtoany.com/add_to/reddit?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F06%2Fgrails-custom-parent-child-aware-tags%2F&amp;linkname=Grails%3A%20Custom%20Parent%2FChild%20Aware%20Tags" title="Reddit" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/reddit.png" width="16" height="16" alt="Reddit"/></a><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F06%2Fgrails-custom-parent-child-aware-tags%2F&amp;linkname=Grails%3A%20Custom%20Parent%2FChild%20Aware%20Tags" title="Delicious" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_button_evernote" href="http://www.addtoany.com/add_to/evernote?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F06%2Fgrails-custom-parent-child-aware-tags%2F&amp;linkname=Grails%3A%20Custom%20Parent%2FChild%20Aware%20Tags" title="Evernote" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/evernote.png" width="16" height="16" alt="Evernote"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F06%2Fgrails-custom-parent-child-aware-tags%2F&amp;title=Grails%3A%20Custom%20Parent%2FChild%20Aware%20Tags" id="wpa2a_10">Share/Bookmark</a></p>
]]></content:encoded>
			<wfw:commentRss>http://pathfindersoftware.com/2009/06/grails-custom-parent-child-aware-tags/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Remove/Cancel Bubbling for an Event in Flex3</title>
		<link>http://pathfindersoftware.com/2009/04/remove-bubbling-for-an-event-in-flex3/</link>
		<comments>http://pathfindersoftware.com/2009/04/remove-bubbling-for-an-event-in-flex3/#comments</comments>
		<pubDate>Thu, 30 Apr 2009 20:18:15 +0000</pubDate>
		<dc:creator>Anthony Caliendo</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Technologies and Platforms]]></category>
		<category><![CDATA[Flex3]]></category>
		<category><![CDATA[flexunit]]></category>

		<guid isPermaLink="false">http://www.pathf.com/blogs/?p=2243</guid>
		<description><![CDATA[I recently had an issue in flex where I needed the click event for a component in an ItemRenderer to not bubble up to the parent list. Since the click event was being dispatched by Flex SDK code, I could not directly do this by passing false into the event&#8217;s constructor. I had hoped to ...]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F04%2Fremove-bubbling-for-an-event-in-flex3%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F04%2Fremove-bubbling-for-an-event-in-flex3%2F&amp;source=PathSoft&amp;style=normal&amp;service=bit.ly&amp;service_api=R_8a1154b608af9e55718b231fb0025d40&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<div class="right">
<img src="http://pathfindersoftware.com/wp-content/uploads/fx_icon_special_100x1001.jpg" alt="fx_icon_special_100x100" width="100" height="100" class="alignnone size-full wp-image-2245" />
</div>
<p>I recently had an issue in flex where I needed the click event for a component in an ItemRenderer to not bubble up to the parent list.  Since the click event was being dispatched by Flex SDK code, I could not directly do this by passing <code>false</code> into the event&#8217;s constructor.  I had hoped to find a property I could set on the object, something like &#8220;clickBubbles&#8221;, which I could set which would accomplish this.</p>
<p>Either that property doesn&#8217;t exist or I could not find it.  My solution was to basically hijack the event and send an impersonator in its place.</p>
<p><span id="more-2243"></span></p>
<p>What I ended up doing was writing an event listener function which would stop propagation on the event.  It would then dispatch another event with the same properties as the original, except it would set <code>bubbles</code> to <code>false</code>.  This will prevent the event from bubbling up to parent components, but still allow event listeners to be added to the component itself.</p>
<p>The following is the function I wrote:</p>
<pre lang="actionscript">
private function removeMouseEventBubble(event:MouseEvent):void {
	// if the event already does not bubble, we don't
	// need to do anything.
	// also, this will prevent any infinite loops from occurring
	if (event.bubbles) {
		// stop the event from being handled by other code
		event.stopImmediatePropagation();

		// dispatch a new event which does not bubble
		event.target.dispatchEvent(
			new MouseEvent(
				event.type, false, event.cancelable,
				event.localX, event.localY,
				event.relatedObject,
				event.ctrlKey, event.altKey,
				event.shiftKey, event.buttonDown,
				event.delta
			)
		);
	}
}
</pre>
<p>Now, all you need to do is set the click handler on the component:</p>
<pre lang="xml">
<components:Foo click="removeMouseEventBubble(event)"/>
</pre>
<p>In order to make sure that this code prevented the original event from propagating and to ensure that it dispatched a similar event which does not bubble, I wrote the following <a href="http://opensource.adobe.com/wiki/display/flexunit/FlexUnit">FlexUnit</a> test. <em>N.B. This code is adapted from an actual test, I wouldn&#8217;t recommend having the code under test defined in the test case itself, nor do I like the fact that the </em><code>removeMouseEventBubble</code><em> function is being added in the test</em>.</p>
<pre lang="actionscript">
public function testShouldRemoveBubbleOnClickButAllowEventListenersToStillFire():void {
	var component:UIComponent = new UIComponent();
	component.addEventListener(
		MouseEvent.CLICK, removeMouseEventBubble
	);

	// if we cannot add other event listeners, then the
	// async function will not get fired and the test will fail.
	component.addEventListener(MouseEvent.CLICK, addAsync(
		function(event:MouseEvent):void {
			assertFalse(event.bubbles);

			// assert that the event was translated properly
			assertEquals(MouseEvent.CLICK, event.type);
			assertTrue(event.cancelable);
			assertEquals(8, event.localX);
			assertEquals(9, event.localY);
			assertEquals(renderer, event.relatedObject);
			assertTrue(event.ctrlKey);
			assertTrue(event.altKey);
			assertTrue(event.shiftKey);
			assertTrue(event.buttonDown);
			assertEquals(5, event.delta);
		}, 1000)
	);

	component.dispatchEvent(
		new MouseEvent(
			MouseEvent.CLICK, true, true, 8,
			9, renderer, true, true, true, true, 5
		)
	);
}
</pre>
<p>I then wrote a test to verify that the event did not bubble up to the parent:</p>
<pre lang="actionscript">
public function testShouldNotBubbleClickEventToParent():void {
	var parent:UIComponent = new UIComponent();
	parent.addEventListener(MouseEvent.CLICK,
		function(event:MouseEvent):void {
			// this won't cause the test to fail per say,
			// but it will cause an exception to be thrown
			// and this will show up when executing the
			// test.  This will fail the build, especially
			// if run on a CI server like hudson or cruise.
			fail('did not expect event to bubble');
		}
	);

	var child:UIComponent = new UIComponent();
	child.addEventListener(
		MouseEvent.CLICK, removeMouseEventBubble
	);
	parent.addChild(child);

	child.dispatchEvent(new MouseEvent(MouseEvent.CLICK));
}
</pre>
<p>This solution works, but I was hoping there was something more elegant and less hacky which accomplished the same thing.
<p><a class="a2a_button_linkedin" href="http://www.addtoany.com/add_to/linkedin?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F04%2Fremove-bubbling-for-an-event-in-flex3%2F&amp;linkname=Remove%2FCancel%20Bubbling%20for%20an%20Event%20in%20Flex3" title="LinkedIn" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/linkedin.png" width="16" height="16" alt="LinkedIn"/></a><a class="a2a_button_stumbleupon" href="http://www.addtoany.com/add_to/stumbleupon?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F04%2Fremove-bubbling-for-an-event-in-flex3%2F&amp;linkname=Remove%2FCancel%20Bubbling%20for%20an%20Event%20in%20Flex3" title="StumbleUpon" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/stumbleupon.png" width="16" height="16" alt="StumbleUpon"/></a><a class="a2a_button_digg" href="http://www.addtoany.com/add_to/digg?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F04%2Fremove-bubbling-for-an-event-in-flex3%2F&amp;linkname=Remove%2FCancel%20Bubbling%20for%20an%20Event%20in%20Flex3" title="Digg" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/digg.png" width="16" height="16" alt="Digg"/></a><a class="a2a_button_dzone" href="http://www.addtoany.com/add_to/dzone?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F04%2Fremove-bubbling-for-an-event-in-flex3%2F&amp;linkname=Remove%2FCancel%20Bubbling%20for%20an%20Event%20in%20Flex3" title="DZone" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/dzone.png" width="16" height="16" alt="DZone"/></a><a class="a2a_button_reddit" href="http://www.addtoany.com/add_to/reddit?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F04%2Fremove-bubbling-for-an-event-in-flex3%2F&amp;linkname=Remove%2FCancel%20Bubbling%20for%20an%20Event%20in%20Flex3" title="Reddit" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/reddit.png" width="16" height="16" alt="Reddit"/></a><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F04%2Fremove-bubbling-for-an-event-in-flex3%2F&amp;linkname=Remove%2FCancel%20Bubbling%20for%20an%20Event%20in%20Flex3" title="Delicious" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_button_evernote" href="http://www.addtoany.com/add_to/evernote?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F04%2Fremove-bubbling-for-an-event-in-flex3%2F&amp;linkname=Remove%2FCancel%20Bubbling%20for%20an%20Event%20in%20Flex3" title="Evernote" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/evernote.png" width="16" height="16" alt="Evernote"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F04%2Fremove-bubbling-for-an-event-in-flex3%2F&amp;title=Remove%2FCancel%20Bubbling%20for%20an%20Event%20in%20Flex3" id="wpa2a_12">Share/Bookmark</a></p>
]]></content:encoded>
			<wfw:commentRss>http://pathfindersoftware.com/2009/04/remove-bubbling-for-an-event-in-flex3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Unit Testing: Can You Afford Not To?</title>
		<link>http://pathfindersoftware.com/2009/04/unit-testing-can-you-afford-not-to/</link>
		<comments>http://pathfindersoftware.com/2009/04/unit-testing-can-you-afford-not-to/#comments</comments>
		<pubDate>Wed, 01 Apr 2009 10:43:01 +0000</pubDate>
		<dc:creator>Anthony Caliendo</dc:creator>
				<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Testing]]></category>

		<guid isPermaLink="false">http://www.pathf.com/blogs/?p=1861</guid>
		<description><![CDATA[50 Cent&#8217;s unit test based savings Unit testing is fairly common these days as more and more people understand the benefits; however, you may still run into a client or manager who is not convinced. These people tend to think unit testing increases development time and cost, or they feel that unit tests are redundant ...]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F04%2Funit-testing-can-you-afford-not-to%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F04%2Funit-testing-can-you-afford-not-to%2F&amp;source=PathSoft&amp;style=normal&amp;service=bit.ly&amp;service_api=R_8a1154b608af9e55718b231fb0025d40&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<div class="right">
<img class="alignnone size-full wp-image-1869" src="http://pathfindersoftware.com/wp-content/uploads/fitty_cent1.jpg" alt="fitty_cent" width="240" height="199" /></p>
<p class="smaller">50 Cent&#8217;s unit test based savings</p>
</div>
<p>Unit testing is fairly common these days as more and more people understand the benefits; however, you may still run into a client or manager who is not convinced.  These people tend to think unit testing increases development time and cost, or they feel that unit tests are redundant since a QA department is also testing the application.  If you&#8217;ve ever heard &#8220;we don&#8217;t have time for unit tests&#8221;, &#8220;you&#8217;re a developer, leave testing to QA&#8221;, or &#8220;I&#8217;m not paying you to write tests&#8221; then you know what I&#8217;m talking about.</p>
<p>These encounters can be quite frustrating for a developer or project manager who wants to leverage unit testing.  While there might be a temptation to just unit test anyway without the blessing of a client or manager, it is more useful to help these people understand why they are mistaken about unit tests.  I have found that this misunderstanding is often because they don&#8217;t realize that testing is actually a cost <em>saver</em> instead of just an additional cost.</p>
<p>But how to vocalize this point in a way they will understand?</p>
<p><span id="more-1861"></span></p>
<p>The bottom line is that unit tests save time and therefore money.  This is a common stumbling point for people to understand (especially non-technical people) since it is counterintuitive.  To them, testing is just &#8220;more code&#8221; so it has to increase development time and cost.  To combat this erroneous perception, it is important to point out how unit tests save time for both developers and QA.</p>
<p>Unit testing reduces the time it takes for the developer to verify their code.  Instead of needing to find out if this bit of code which is in the middle of a long workflow works, I can write and run a targeted unit test in less time than it takes to fire up the app, login in, start the workflow, goto the exact spot in the workflow, etc.  Since the test is repeatable and automated, writing the test is a one time cost which I can then easily re-run to verify my code at any point in time and for as many times as needed.  This becomes an even bigger time saver when code needs to be changed.  Everyone makes mistakes, and it is easy to accidentally break something when making a change to several month old code which you didn&#8217;t write.  Unit tests help ensure that a developer catches any mistakes right when they happen, and allows them to be fixed quickly.</p>
<p>It is at this point that QA is often brought up: &#8220;a developer doesn&#8217;t need to verify code because QA takes care of that&#8221;.  At these times, it is important to point out how the QA process is more costly, especially if the issue could have been prevented with a unit test.</p>
<p>If someone in QA notices a problem, they need to stop verifying other parts of the application to deal with the problem.  You have just reduced their productivity.  Now, the QA person needs to write up a ticket which includes detailed instructions of how to recreate the problem.  You have just increased the amount of work needed to be done by QA.  Now, the developer gets the ticket and needs to take a look at the issue instead of working on new features.  You have just caused the developer to context switch, which reduces their productivity.  If the issue is for code the developer wrote a while ago (or didn&#8217;t write at all), they need to spend time getting familiar with the code.  Again, more context switching and more time spent not adding new features.  Even after fixing the issue, the QA person will still need to verify the fix by retesting that same part of the application.  The QA person is made even less productive because they are testing that part of the system again instead of parts which haven&#8217;t been tested yet.</p>
<p>Now, imagine how much more time is spent if the developer is having problems reproducing the issue or if the QA person notices the problem isn&#8217;t really fixed and needs to reopen the issue.  You will need to repeat most of that process, further compounding time spent.  What happens down the line when code is changed and this specific issue occurs again?  Yup,  you have to do this whole dance <em>again</em>.</p>
<p>Unit tests won&#8217;t prevent this from happening all the time, nor will it handle the kind of complex scenarios and verifications which QA does which are difficult to do in a unit test.  However, it will significantly cut down on the number of easily preventable issues which detract QA from doing more important testing (and the developer from focusing on new features).  When the developer writes a unit test to prove the issue is fixed, he will be preventing it from happening again in the future (which means time is saved because the issue won&#8217;t be reopened or crop back up some point in the future).</p>
<p>Basically, unit tests are a way to automate certain parts of the development and QA process which don&#8217;t need to be done by a human every time.  This allows a more streamlined process which makes developers and QA people more efficient and productive, and frees them up to focus on things which generate revenue instead of hunting and fixing bugs which didn&#8217;t need to be there in the first place.</p>
<p>There are plenty more reasons why unit tests save time (the design benefits coming from TDD is certainly not to be forgotten); however, I have found this example to be the most effective because it is the easiest for non-technical people to visualize the cause and effect relationship unit tests have on the bottom line.
<p><a class="a2a_button_linkedin" href="http://www.addtoany.com/add_to/linkedin?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F04%2Funit-testing-can-you-afford-not-to%2F&amp;linkname=Unit%20Testing%3A%20Can%20You%20Afford%20Not%20To%3F" title="LinkedIn" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/linkedin.png" width="16" height="16" alt="LinkedIn"/></a><a class="a2a_button_stumbleupon" href="http://www.addtoany.com/add_to/stumbleupon?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F04%2Funit-testing-can-you-afford-not-to%2F&amp;linkname=Unit%20Testing%3A%20Can%20You%20Afford%20Not%20To%3F" title="StumbleUpon" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/stumbleupon.png" width="16" height="16" alt="StumbleUpon"/></a><a class="a2a_button_digg" href="http://www.addtoany.com/add_to/digg?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F04%2Funit-testing-can-you-afford-not-to%2F&amp;linkname=Unit%20Testing%3A%20Can%20You%20Afford%20Not%20To%3F" title="Digg" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/digg.png" width="16" height="16" alt="Digg"/></a><a class="a2a_button_dzone" href="http://www.addtoany.com/add_to/dzone?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F04%2Funit-testing-can-you-afford-not-to%2F&amp;linkname=Unit%20Testing%3A%20Can%20You%20Afford%20Not%20To%3F" title="DZone" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/dzone.png" width="16" height="16" alt="DZone"/></a><a class="a2a_button_reddit" href="http://www.addtoany.com/add_to/reddit?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F04%2Funit-testing-can-you-afford-not-to%2F&amp;linkname=Unit%20Testing%3A%20Can%20You%20Afford%20Not%20To%3F" title="Reddit" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/reddit.png" width="16" height="16" alt="Reddit"/></a><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F04%2Funit-testing-can-you-afford-not-to%2F&amp;linkname=Unit%20Testing%3A%20Can%20You%20Afford%20Not%20To%3F" title="Delicious" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_button_evernote" href="http://www.addtoany.com/add_to/evernote?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F04%2Funit-testing-can-you-afford-not-to%2F&amp;linkname=Unit%20Testing%3A%20Can%20You%20Afford%20Not%20To%3F" title="Evernote" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/evernote.png" width="16" height="16" alt="Evernote"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F04%2Funit-testing-can-you-afford-not-to%2F&amp;title=Unit%20Testing%3A%20Can%20You%20Afford%20Not%20To%3F" id="wpa2a_14">Share/Bookmark</a></p>
]]></content:encoded>
			<wfw:commentRss>http://pathfindersoftware.com/2009/04/unit-testing-can-you-afford-not-to/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Notification Testing with PureMVC and FlexUnit</title>
		<link>http://pathfindersoftware.com/2009/03/notification-testing-with-puremvc-and-flexunit/</link>
		<comments>http://pathfindersoftware.com/2009/03/notification-testing-with-puremvc-and-flexunit/#comments</comments>
		<pubDate>Wed, 11 Mar 2009 10:00:04 +0000</pubDate>
		<dc:creator>Anthony Caliendo</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Technologies and Platforms]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[flexunit]]></category>
		<category><![CDATA[PureMVC]]></category>
		<category><![CDATA[Testing]]></category>

		<guid isPermaLink="false">http://www.pathf.com/blogs/?p=1527</guid>
		<description><![CDATA[One of the nice extensions available for FlexUnit is the ability to easily unit test event behavior using EventfulTestCase. This library has support for testing Cairngorm, but unfortunately support is lacking for PureMVC. I searched for existing solutions which added PureMVC notification support, but was not satisfied with their APIs. Luckily, it was not difficult ...]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F03%2Fnotification-testing-with-puremvc-and-flexunit%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F03%2Fnotification-testing-with-puremvc-and-flexunit%2F&amp;source=PathSoft&amp;style=normal&amp;service=bit.ly&amp;service_api=R_8a1154b608af9e55718b231fb0025d40&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<div class="right"><img src="http://pathfindersoftware.com/wp-content/uploads/flex-puremvc1.png" alt="flex-puremvc" width="114" height="81" class="alignnone size-full wp-image-1532" /></div>
<p>One of the nice extensions available for <a href="http://opensource.adobe.com/wiki/display/flexunit/FlexUnit">FlexUnit</a> is the ability to easily unit test event behavior using <a href="http://blogs.adobe.com/tomsugden/2008/01/post.html">EventfulTestCase</a>.</p>
<p>This library has support for testing <a href="http://opensource.adobe.com/wiki/display/cairngorm/Cairngorm">Cairngorm</a>, but unfortunately support is lacking for <a href="http://puremvc.org/component/option,com_wrapper/Itemid,144/">PureMVC</a>.  I searched for existing solutions which added PureMVC notification support, but was not satisfied with their APIs.  Luckily, it was not difficult to write some code to support PureMVC which mirrored the API of <code>EventfulTestCase</code>.</p>
<p><span id="more-1527"></span></p>
<p>The code at the end of this post is a start at duplicating the <code>EventfulTestCase</code> behavior.  It doesn&#8217;t have all the functionality, but it is enough for simple tests.</p>
<p>Here are the methods which are made available:</p>
<ul>
<li><strong>expectNotification(notificationName:String)</strong> Sets up the expectation that a notification is sent with the passed name.  Can be called multiple times to set the expectation for multiple notifications.</li>
<li><strong>assertExpectedNotificationsOccurred(userMessage=&#8221;)</strong> Asserts that all expected notifications were sent.  The <code>userMessage</code> parameter indicates an optional message to be prepended for a failure message.</li>
<li><strong>lastActualNotification</strong> Property which represents the last notification which was sent (the last actual notification).</li>
</ul>
<p>The following is an example of the kind of test you can write:</p>
<pre lang="actionscript">
public class ChuckProxyTest extends PureMvcTestCase
{
    private var chuck:ChuckProxy = new ChuckProxy();

    public function testShouldSendFlashNotificationWhenSeeingTerrorist():void
    {
        var terrorist:Terrorist = new Terrorist();
        expectNotification(ApplicationFacade.FLASHED);

        chuck.lookAt(terrorist);

        // asserts FLASHED notification was sent
        assertExpectedNotificationsOccurred();
        // asserts notification body was the terrorist
        assertEquals(terrorist, lastActualNotification.getBody());
    }
}
</pre>
<p>Finally, here is the code.  Notice the package; you will need to add it to <em>test/org/puremvc/as3/test</em>.</p>
<pre lang="actionscript">
package org.puremvc.as3.test
{
    import flexunit.framework.AssertionFailedError;
    import flexunit.framework.TestCase;

    import org.puremvc.as3.core.View;
    import org.puremvc.as3.interfaces.INotification;
    import org.puremvc.as3.patterns.observer.Observer;

    public class PureMvcTestCase extends TestCase
    {

        private var expectedNotificationNames:Array = [];
        private var actualNotifications:Array = [];

        public function PureMvcTestCase(methodName:String=null)
        {
            super(methodName);
        }

        protected function expectNotification(notificationName:String):void
        {
            assertNotNull('No instance exists for View.getInstance()', View.getInstance());
            expectedNotificationNames.push(notificationName);

            View.getInstance().registerObserver(notificationName, new Observer(
                function(notification:INotification):void {
                    actualNotifications.push(notification);
                },
                null));
        }

        protected function get lastActualNotification():INotification
        {
            if (actualNotifications.length == 0) {
                return null;
            }
            return actualNotifications[actualNotifications.length - 1];
        }

        protected function assertExpectedNotificationsOccurred(userMessage='The expected notifications were not sent'):void
        {
            var actualNotificationNames:Array = [];

            for(var notificationIndex:int = 0; notificationIndex < actualNotifications.length; notificationIndex++) {
                actualNotificationNames.push(actualNotifications[notificationIndex].getName());
            }

            assertArraysEqual(expectedNotificationNames, actualNotificationNames, userMessage);
        }

        protected function assertArraysEqual(expected:Array, actual:Array, userMessage:String = null):void
        {
            var equal:Boolean = (expected.length == actual.length);

            if (equal) {
                for(var i:int = 0; i < actualNotifications.length; i++) {
                    if (expected[i] != actual[i]) {
                        equal = false;
                        break;
                    }
                }
            }

            if (!equal) {
                if (userMessage &amp;&amp; userMessage.length > 0) {
                    userMessage += ' - ';
                }

                throw new AssertionFailedError(userMessage + 'Expected: <' + expected + '> but was: <' + actual + '>');
            }
        }
    }
}
</pre>
<p><a class="a2a_button_linkedin" href="http://www.addtoany.com/add_to/linkedin?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F03%2Fnotification-testing-with-puremvc-and-flexunit%2F&amp;linkname=Notification%20Testing%20with%20PureMVC%20and%20FlexUnit" title="LinkedIn" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/linkedin.png" width="16" height="16" alt="LinkedIn"/></a><a class="a2a_button_stumbleupon" href="http://www.addtoany.com/add_to/stumbleupon?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F03%2Fnotification-testing-with-puremvc-and-flexunit%2F&amp;linkname=Notification%20Testing%20with%20PureMVC%20and%20FlexUnit" title="StumbleUpon" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/stumbleupon.png" width="16" height="16" alt="StumbleUpon"/></a><a class="a2a_button_digg" href="http://www.addtoany.com/add_to/digg?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F03%2Fnotification-testing-with-puremvc-and-flexunit%2F&amp;linkname=Notification%20Testing%20with%20PureMVC%20and%20FlexUnit" title="Digg" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/digg.png" width="16" height="16" alt="Digg"/></a><a class="a2a_button_dzone" href="http://www.addtoany.com/add_to/dzone?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F03%2Fnotification-testing-with-puremvc-and-flexunit%2F&amp;linkname=Notification%20Testing%20with%20PureMVC%20and%20FlexUnit" title="DZone" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/dzone.png" width="16" height="16" alt="DZone"/></a><a class="a2a_button_reddit" href="http://www.addtoany.com/add_to/reddit?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F03%2Fnotification-testing-with-puremvc-and-flexunit%2F&amp;linkname=Notification%20Testing%20with%20PureMVC%20and%20FlexUnit" title="Reddit" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/reddit.png" width="16" height="16" alt="Reddit"/></a><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F03%2Fnotification-testing-with-puremvc-and-flexunit%2F&amp;linkname=Notification%20Testing%20with%20PureMVC%20and%20FlexUnit" title="Delicious" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_button_evernote" href="http://www.addtoany.com/add_to/evernote?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F03%2Fnotification-testing-with-puremvc-and-flexunit%2F&amp;linkname=Notification%20Testing%20with%20PureMVC%20and%20FlexUnit" title="Evernote" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/evernote.png" width="16" height="16" alt="Evernote"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F03%2Fnotification-testing-with-puremvc-and-flexunit%2F&amp;title=Notification%20Testing%20with%20PureMVC%20and%20FlexUnit" id="wpa2a_16">Share/Bookmark</a></p>
]]></content:encoded>
			<wfw:commentRss>http://pathfindersoftware.com/2009/03/notification-testing-with-puremvc-and-flexunit/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Grails: Delegating to GORM Persistence in Java</title>
		<link>http://pathfindersoftware.com/2009/02/grails-delegating-to-gorm-persistence-in-java/</link>
		<comments>http://pathfindersoftware.com/2009/02/grails-delegating-to-gorm-persistence-in-java/#comments</comments>
		<pubDate>Thu, 12 Feb 2009 05:43:13 +0000</pubDate>
		<dc:creator>Anthony Caliendo</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Technologies and Platforms]]></category>
		<category><![CDATA[GORM]]></category>
		<category><![CDATA[Grails]]></category>
		<category><![CDATA[Groovy]]></category>

		<guid isPermaLink="false">http://www.pathf.com/blogs/?p=1392</guid>
		<description><![CDATA[For a recent project, I needed to plug some Java code into a Grails app. I wanted to use GORM for persistence, but couldn&#8217;t introduce the interfaces, proxies, and factories into the java code which is required for existing solutions to this problem. Basically, my constraint was that the java code itself couldn&#8217;t be altered ...]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F02%2Fgrails-delegating-to-gorm-persistence-in-java%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F02%2Fgrails-delegating-to-gorm-persistence-in-java%2F&amp;source=PathSoft&amp;style=normal&amp;service=bit.ly&amp;service_api=R_8a1154b608af9e55718b231fb0025d40&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<div class="right"><a href="http://pathfindersoftware.com/wp-content/uploads/grails_logo1.png"><img class="alignnone size-medium wp-image-1393" src="http://pathfindersoftware.com/wp-content/uploads/grails_logo1.png" alt="" width="196" height="53" /></a></div>
<p>For a recent project, I needed to plug some Java code into a Grails app.  I wanted to use GORM for persistence, but couldn&#8217;t introduce the interfaces, proxies, and factories into the java code which is required for existing solutions to this problem.</p>
<p>Basically, my constraint was that the java code itself couldn&#8217;t be altered to work inside the grails app.  The solution I came up with is pretty simple, but works well.</p>
<p><span id="more-1392"></span></p>
<p>The java code delegated to a DAO for persistence (using an interface).  Here is what it looked like:</p>
<pre lang="java5">package org.smurf;

import java.util.List;

class SmurfingServiceImpl implements SmurfingService {
    private final SmurfDao smurfDao;

    public SmurfingServiceImpl(SmurfDao smurfDao) {
        this.smurfDao= smurfDao;
    }

    public List listSmurfs() {
        ...
        return smurfDao.findAll();
    }

    public Smurf capture(Smurf smurf) {
        ...
        return smurfDao.update(smurf);
    }
}</pre>
<p>I packaged my groovy domain class to be <code>org.smurf.Smurf</code> so that the java code would be using the Grails generated class.  Depending on the situation, this could involve a little bit of tweaking to the grails domain object to be compatible with any existing java classes.  For this example, we&#8217;re assuming an anemic bean so we don&#8217;t need to do anything except declare the properties.</p>
<pre lang="java5">package org.smurf
class Smurf {
  String name
  Boolean captured
}</pre>
<p>Next, I created an abstract DAO which delegates the sort of CRUD operations you see in a DAO to the GORM object.</p>
<pre lang="java5">package org.smurf;

import java.util.List;

public abstract class GormDelegatingDao<t extends groovy.lang.GroovyObject> {

	protected abstract Class<t> getGormClass();

	public T create(T entity) {
		return update(entity);
	}

	public T retrieve(String id) {
		return (T) invokeClassLevelMethod("get", id);
	}

	public T update(T entity) {
		return (T) entity.invokeMethod("save", new Object[0]);
       }

	public T delete(T entity) {
		return (T) invokeClassLevelMethod("delete", entity.getId());
	}

	public List<t> findAll() {
		return (List<t>) invokeClassLevelMethod("list");
	}

	protected Object invokeClassLevelMethod(String method, Object... args) {
		T instance;

		try {
			instance = getGormClass().newInstance();
		} catch (Exception e) {
			throw new RuntimeException(e);
		}

		return instance.invokeMethod(method, args);
	}
}</pre>
<p>After this, I simply needed to implement <code>SmurfDao</code> using this abstract class.</p>
<pre lang="java5">package org.smurf;

class GormSmurfDao extends GormDelegatingDao<smurf> implements SmurfDao {
	protected Class<smurf> getGormClass() {
		return Smurf.class;
	}
}</pre>
<p>Using spring, we just need to make sure an instance of this class is injected into the <code>SmurfingService</code>.  The following is an example using <em>grails-app/conf/spring/resources.xml</em>:</p>
<pre>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"&gt;

  &lt;bean class="org.smurf.GormSmurfDao" autowire="constructor"/&gt;

  &lt;bean id="smurfingService" class="org.smurf.SmurfingServiceImpl" autowire="constructor"/&gt;

&lt;/beans&gt;</pre>
<p>I can now access this service in a controller (or grails service), and it will properly persist my changes without me needing to set up any additional configuration or changing the existing java code.</p>
<p>It is entirely possible to dynamically generate the DAO implementations for each domain class.  You could even use a factory and proxy pattern to create them on the fly if you wanted to be really slick.</p>
<p>For a real world application, there are probably operations outside of CRUD which you would need to deal with (e.g. complex finders).  Using the general concept presented here, it wouldn&#8217;t be difficult to delegate these finders to GORM.
<p><a class="a2a_button_linkedin" href="http://www.addtoany.com/add_to/linkedin?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F02%2Fgrails-delegating-to-gorm-persistence-in-java%2F&amp;linkname=Grails%3A%20Delegating%20to%20GORM%20Persistence%20in%20Java" title="LinkedIn" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/linkedin.png" width="16" height="16" alt="LinkedIn"/></a><a class="a2a_button_stumbleupon" href="http://www.addtoany.com/add_to/stumbleupon?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F02%2Fgrails-delegating-to-gorm-persistence-in-java%2F&amp;linkname=Grails%3A%20Delegating%20to%20GORM%20Persistence%20in%20Java" title="StumbleUpon" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/stumbleupon.png" width="16" height="16" alt="StumbleUpon"/></a><a class="a2a_button_digg" href="http://www.addtoany.com/add_to/digg?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F02%2Fgrails-delegating-to-gorm-persistence-in-java%2F&amp;linkname=Grails%3A%20Delegating%20to%20GORM%20Persistence%20in%20Java" title="Digg" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/digg.png" width="16" height="16" alt="Digg"/></a><a class="a2a_button_dzone" href="http://www.addtoany.com/add_to/dzone?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F02%2Fgrails-delegating-to-gorm-persistence-in-java%2F&amp;linkname=Grails%3A%20Delegating%20to%20GORM%20Persistence%20in%20Java" title="DZone" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/dzone.png" width="16" height="16" alt="DZone"/></a><a class="a2a_button_reddit" href="http://www.addtoany.com/add_to/reddit?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F02%2Fgrails-delegating-to-gorm-persistence-in-java%2F&amp;linkname=Grails%3A%20Delegating%20to%20GORM%20Persistence%20in%20Java" title="Reddit" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/reddit.png" width="16" height="16" alt="Reddit"/></a><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F02%2Fgrails-delegating-to-gorm-persistence-in-java%2F&amp;linkname=Grails%3A%20Delegating%20to%20GORM%20Persistence%20in%20Java" title="Delicious" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_button_evernote" href="http://www.addtoany.com/add_to/evernote?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F02%2Fgrails-delegating-to-gorm-persistence-in-java%2F&amp;linkname=Grails%3A%20Delegating%20to%20GORM%20Persistence%20in%20Java" title="Evernote" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/evernote.png" width="16" height="16" alt="Evernote"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F02%2Fgrails-delegating-to-gorm-persistence-in-java%2F&amp;title=Grails%3A%20Delegating%20to%20GORM%20Persistence%20in%20Java" id="wpa2a_18">Share/Bookmark</a></p>
]]></content:encoded>
			<wfw:commentRss>http://pathfindersoftware.com/2009/02/grails-delegating-to-gorm-persistence-in-java/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>ActionMailer Callbacks: In the Spirit of ActionController Filters</title>
		<link>http://pathfindersoftware.com/2009/01/actionmailer-callbacks-in-the-spirit-of-actioncontroller-filters/</link>
		<comments>http://pathfindersoftware.com/2009/01/actionmailer-callbacks-in-the-spirit-of-actioncontroller-filters/#comments</comments>
		<pubDate>Wed, 21 Jan 2009 18:12:05 +0000</pubDate>
		<dc:creator>Anthony Caliendo</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Technologies and Platforms]]></category>
		<category><![CDATA[ActionMailer]]></category>
		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://www.pathf.com/blogs/?p=1374</guid>
		<description><![CDATA[One of the most useful features of ActionController is the ability to add filters before, after, or around actions.  This tool is made even more powerful by the ability to chain filters together.  Allowing an AOP approach is indispensable for addressing cross cutting concerns (or simply separating concerns), and is one of the things which ...]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F01%2Factionmailer-callbacks-in-the-spirit-of-actioncontroller-filters%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F01%2Factionmailer-callbacks-in-the-spirit-of-actioncontroller-filters%2F&amp;source=PathSoft&amp;style=normal&amp;service=bit.ly&amp;service_api=R_8a1154b608af9e55718b231fb0025d40&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<div class="right"><a href="http://pathfindersoftware.com/wp-content/uploads/rails4.png"><img src="http://pathfindersoftware.com/wp-content/uploads/rails4.png" alt="" width="50" height="64" class="alignnone size-medium wp-image-1100" /></a></div>
<p>One of the most useful features of <code>ActionController</code> is the ability to add filters before, after, or around actions.  This tool is made even more powerful by the ability to chain filters together.  Allowing an AOP approach is indispensable for addressing cross cutting concerns (or simply separating concerns), and is one of the things which makes a framework valuable to a developer (<a href="http://www.springsource.org/">Spring</a> is an excellent example of this).</p>
<p>A while back, I had a requirement to persist a record of which email addresses were sent an email through the system.  I expected to find callback support for <code>ActionMailer</code>, but was surprised to find that it didn&#8217;t exist.</p>
<p>I had three options: put the logic inline in each <code>ActionMailer</code> method which is not DRY and muddles concerns, put the logic in the <code>ActionContoller</code> as filters which break encapsulation in terrible ways (and is at the wrong layer), or extend <code>ActionMailler</code> to allow callback methods.</p>
<p>I choose the latter&#8230;</p>
<p><span id="more-1374"></span><br />
I created a simple plugin which allows you to add before and after deliver callbacks to <code>ActionMailer</code>, and constrain them to certain methods using <code> <img src='http://pathfindersoftware.com/wp-includes/images/smilies/icon_surprised.gif' alt=':o' class='wp-smiley' /> nly</code> and <code>:except</code> options ala <code>ActionController</code>&#8216;s filters.</p>
<p>You can add the plugin by executing the following in your rails app directory:</p>
<blockquote><p><strong>script/plugin install git://github.com/AnthonyCaliendo/action_mailer_callbacks.git</strong></p></blockquote>
<p>Here is a snipet from the readme:</p>
<pre>
There are 2 main ways to define a callback. In each case, the callback method/block is passed the mail object as the
only argument.

You may define a callback using a block:
class FooMailer &lt; ActionMailer::Base
  after_deliver do |mail|
    ...
  end
end

You may also define a callback using a symbol/string for a method name:
class FooMailer &lt; ActionMailer::Base
  before_deliver :append_advertisement

  def append_advertisement(mail)
    ...
  end
end

Callbacks take options which can be used to define which mail types (i.e. methods) they will be applied to.
These options take the format of *only* and *except*.
  - An *only* callback will only be run for methods which match the passed method names.
  - An *except* callback will be called for all methods EXCEPT those that match the passed method names
The options can take either an array of strings/symbols, or a single string/symbol.

class FooMailer &lt; ActionMailer::Base
  before_deliver :append_disclaimer, <img src='http://pathfindersoftware.com/wp-includes/images/smilies/icon_surprised.gif' alt=':o' class='wp-smiley' /> nly =&gt; [:email_friend, :announce_something]
  after_deliver :notify_user, :except =&gt; :invite_user

 ...
end

== What About Halting the Chain?

You can halt the chain in either a before or after callback.  In order to do this, just call +halt_callback_chain+ in
the block (or +self.class.halt_callback_chain+ in an instance method).
If the chain is halted in a before callback, the email will *NOT* be delivered and no other callbacks will be invoked
(either any after callbacks or any remaining before callbacks).
If the chain is halted in an after callback, the email will have already been sent and all before callbacks would have
run, but any remaining after callbacks will not be invoked.

class FooMailer &lt; ActionMailer::Base
  before_deliver do |mail|
    halt_callback_chain if invalid_mail?(mail)
  end

  after_deliver :abort

  def abort(mail)
    self.class.halt_callback_chain
  end
end
</pre>
<p>I wanted to keep usage similar to how filters are handled in <code>ActionController</code>, so I decided against using the return value of the callback to halt the chain.  Instead, you explicitly halt the chain similar to how rendering or redirecting halts a <code>before_filter</code> chain in a controller.</p>
<p>I am hosting the code on github at <strong><a href="http://github.com/AnthonyCaliendo/action_mailer_callbacks/tree/master">http://github.com/AnthonyCaliendo/action_mailer_callbacks/tree/master</a></strong>.  I was time constrained when I wrote this, but I will be cleaning up the code once I get a chance (I promise!).</p>
<p>I wrote this code months ago (just now got around to blogging about it and releasing it to github), but while researching this blog post I saw that someone else came up with a similar plugin at <a href="http://github.com/kelyar/mailer_callbacks/tree/master">http://github.com/kelyar/mailer_callbacks/tree/master</a>.  Kelyar&#8217;s plugin seems more limited than the one I am providing (plus, there are no tests&#8230; tsk tsk!), but it is cleaner and simpler.  It may be worth taking a look at that as well.
<p><a class="a2a_button_linkedin" href="http://www.addtoany.com/add_to/linkedin?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F01%2Factionmailer-callbacks-in-the-spirit-of-actioncontroller-filters%2F&amp;linkname=ActionMailer%20Callbacks%3A%20In%20the%20Spirit%20of%20ActionController%20Filters" title="LinkedIn" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/linkedin.png" width="16" height="16" alt="LinkedIn"/></a><a class="a2a_button_stumbleupon" href="http://www.addtoany.com/add_to/stumbleupon?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F01%2Factionmailer-callbacks-in-the-spirit-of-actioncontroller-filters%2F&amp;linkname=ActionMailer%20Callbacks%3A%20In%20the%20Spirit%20of%20ActionController%20Filters" title="StumbleUpon" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/stumbleupon.png" width="16" height="16" alt="StumbleUpon"/></a><a class="a2a_button_digg" href="http://www.addtoany.com/add_to/digg?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F01%2Factionmailer-callbacks-in-the-spirit-of-actioncontroller-filters%2F&amp;linkname=ActionMailer%20Callbacks%3A%20In%20the%20Spirit%20of%20ActionController%20Filters" title="Digg" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/digg.png" width="16" height="16" alt="Digg"/></a><a class="a2a_button_dzone" href="http://www.addtoany.com/add_to/dzone?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F01%2Factionmailer-callbacks-in-the-spirit-of-actioncontroller-filters%2F&amp;linkname=ActionMailer%20Callbacks%3A%20In%20the%20Spirit%20of%20ActionController%20Filters" title="DZone" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/dzone.png" width="16" height="16" alt="DZone"/></a><a class="a2a_button_reddit" href="http://www.addtoany.com/add_to/reddit?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F01%2Factionmailer-callbacks-in-the-spirit-of-actioncontroller-filters%2F&amp;linkname=ActionMailer%20Callbacks%3A%20In%20the%20Spirit%20of%20ActionController%20Filters" title="Reddit" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/reddit.png" width="16" height="16" alt="Reddit"/></a><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F01%2Factionmailer-callbacks-in-the-spirit-of-actioncontroller-filters%2F&amp;linkname=ActionMailer%20Callbacks%3A%20In%20the%20Spirit%20of%20ActionController%20Filters" title="Delicious" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_button_evernote" href="http://www.addtoany.com/add_to/evernote?linkurl=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F01%2Factionmailer-callbacks-in-the-spirit-of-actioncontroller-filters%2F&amp;linkname=ActionMailer%20Callbacks%3A%20In%20the%20Spirit%20of%20ActionController%20Filters" title="Evernote" rel="nofollow" target="_blank"><img src="http://pathfindersoftware.com/wp-content/plugins/add-to-any/icons/evernote.png" width="16" height="16" alt="Evernote"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fpathfindersoftware.com%2F2009%2F01%2Factionmailer-callbacks-in-the-spirit-of-actioncontroller-filters%2F&amp;title=ActionMailer%20Callbacks%3A%20In%20the%20Spirit%20of%20ActionController%20Filters" id="wpa2a_20">Share/Bookmark</a></p>
]]></content:encoded>
			<wfw:commentRss>http://pathfindersoftware.com/2009/01/actionmailer-callbacks-in-the-spirit-of-actioncontroller-filters/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic (User agent is rejected)
Page Caching using memcached (User agent is rejected)

Served from: pathfindersoftware.com @ 2012-02-09 17:14:06 -->
