<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Removing Duplicate Code in Functions</title>
	<atom:link href="http://elegantcode.com/2008/04/08/removing-duplicate-code-in-functions/feed/" rel="self" type="application/rss+xml" />
	<link>http://elegantcode.com/2008/04/08/removing-duplicate-code-in-functions/</link>
	<description></description>
	<lastBuildDate>Wed, 17 Mar 2010 08:54:42 -0500</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: MarkE</title>
		<link>http://elegantcode.com/2008/04/08/removing-duplicate-code-in-functions/comment-page-1/#comment-24024</link>
		<dc:creator>MarkE</dc:creator>
		<pubDate>Mon, 16 Jun 2008 16:54:43 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2008/04/08/removing-duplicate-code-in-functions/#comment-24024</guid>
		<description>Thanks for this helpful article. I have a similar problem which perhaps can be solved via AOP. Perhaps you can offer some advice.

Say I have a simple common interface in my library IFoo:
interface IFoo { void doSomething(); }

With multiple subclasses Foo1, Foo2, ..., FooN all implementing IFoo differently.
My current approach is to write a single base class Test written against IFoo, and then a test subclass for each implementation of IFoo, which creates an instance of the appropriate type in SetUp.

This works fine, and reworking with AOP would probably be straightforward but might not buy me a great deal.

However, I&#039;ve been asked to support the ability to run from the IDE by right-clicking on a single test function and selecting &quot;Run Test(s)&quot; which I believe is part of the NUnit IDE extension functionality.

Currently this doesn&#039;t work because the only class containing the test function definitions is abstract. I&#039;m having trouble envisaging a way to provide the user with something to click on to run a single invocation of the Test (there are other test framework GUIs but that&#039;s not deemed acceptable).

Do you have any insight on how to make this kind of behavior available ? I was thinking of using AOP and using test subclasses to imply advice, but this still won&#039;t give the user something to click on so now that I&#039;ve written it down, I&#039;m thinking it&#039;s a bit unachievable. Still, I&#039;d be happy for input and this article is in that area.</description>
		<content:encoded><![CDATA[<p>Thanks for this helpful article. I have a similar problem which perhaps can be solved via AOP. Perhaps you can offer some advice.</p>
<p>Say I have a simple common interface in my library IFoo:<br />
interface IFoo { void doSomething(); }</p>
<p>With multiple subclasses Foo1, Foo2, &#8230;, FooN all implementing IFoo differently.<br />
My current approach is to write a single base class Test written against IFoo, and then a test subclass for each implementation of IFoo, which creates an instance of the appropriate type in SetUp.</p>
<p>This works fine, and reworking with AOP would probably be straightforward but might not buy me a great deal.</p>
<p>However, I&#8217;ve been asked to support the ability to run from the IDE by right-clicking on a single test function and selecting &#8220;Run Test(s)&#8221; which I believe is part of the NUnit IDE extension functionality.</p>
<p>Currently this doesn&#8217;t work because the only class containing the test function definitions is abstract. I&#8217;m having trouble envisaging a way to provide the user with something to click on to run a single invocation of the Test (there are other test framework GUIs but that&#8217;s not deemed acceptable).</p>
<p>Do you have any insight on how to make this kind of behavior available ? I was thinking of using AOP and using test subclasses to imply advice, but this still won&#8217;t give the user something to click on so now that I&#8217;ve written it down, I&#8217;m thinking it&#8217;s a bit unachievable. Still, I&#8217;d be happy for input and this article is in that area.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daniel</title>
		<link>http://elegantcode.com/2008/04/08/removing-duplicate-code-in-functions/comment-page-1/#comment-22414</link>
		<dc:creator>Daniel</dc:creator>
		<pubDate>Sat, 31 May 2008 15:48:34 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2008/04/08/removing-duplicate-code-in-functions/#comment-22414</guid>
		<description>Hello Alex
Thank you for this wonderful post. I stumbled over the Postsharp project and was being redirected to your nice article. I think I prefer the delegate approach too. But I must admit that I like the AOP approach either, but sometimes it&#039;s just too much magic under the hood. 

--- begin metapher mode --

It&#039;s almost like having to choose for home security between my best friend or Jack Bauer. Certainly Jack Bauer is the more trained and specialized person for securing my home place than my best friend could ever be but I happen to know my best friend better than Jack Bauer and therefore I have more trust in him ;) 

--- end metapher mode --

Have a nice day</description>
		<content:encoded><![CDATA[<p>Hello Alex<br />
Thank you for this wonderful post. I stumbled over the Postsharp project and was being redirected to your nice article. I think I prefer the delegate approach too. But I must admit that I like the AOP approach either, but sometimes it&#8217;s just too much magic under the hood. </p>
<p>&#8212; begin metapher mode &#8211;</p>
<p>It&#8217;s almost like having to choose for home security between my best friend or Jack Bauer. Certainly Jack Bauer is the more trained and specialized person for securing my home place than my best friend could ever be but I happen to know my best friend better than Jack Bauer and therefore I have more trust in him <img src='http://elegantcode.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  </p>
<p>&#8212; end metapher mode &#8211;</p>
<p>Have a nice day</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Zubair Khan</title>
		<link>http://elegantcode.com/2008/04/08/removing-duplicate-code-in-functions/comment-page-1/#comment-19725</link>
		<dc:creator>Zubair Khan</dc:creator>
		<pubDate>Sun, 13 Apr 2008 16:49:39 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2008/04/08/removing-duplicate-code-in-functions/#comment-19725</guid>
		<description>Nice post Alex. I do have to say that I prefer the delegate method as it more clearly states your intent. 

One problem I have with AOP in general is that the application of an aspect occurs outside the function&#039;s definition. That has always made it hard for developers new to some code to know where to look.

I&#039;m sure one day I&#039;ll find an example of AOP being put to good use beyond the ubiquitous logging example. If anyone knows of such an example please do point me to it.

With the delegate method I might even like to pull that all out in to a method which reads something like RunTestsWithLogging(). Leaving the test methods themselves less noisy.

Thanks for the post, think I&#039;ll go look in to some AOP now!</description>
		<content:encoded><![CDATA[<p>Nice post Alex. I do have to say that I prefer the delegate method as it more clearly states your intent. </p>
<p>One problem I have with AOP in general is that the application of an aspect occurs outside the function&#8217;s definition. That has always made it hard for developers new to some code to know where to look.</p>
<p>I&#8217;m sure one day I&#8217;ll find an example of AOP being put to good use beyond the ubiquitous logging example. If anyone knows of such an example please do point me to it.</p>
<p>With the delegate method I might even like to pull that all out in to a method which reads something like RunTestsWithLogging(). Leaving the test methods themselves less noisy.</p>
<p>Thanks for the post, think I&#8217;ll go look in to some AOP now!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David Starr</title>
		<link>http://elegantcode.com/2008/04/08/removing-duplicate-code-in-functions/comment-page-1/#comment-19633</link>
		<dc:creator>David Starr</dc:creator>
		<pubDate>Thu, 10 Apr 2008 04:44:07 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2008/04/08/removing-duplicate-code-in-functions/#comment-19633</guid>
		<description>Damn, Alex.his is one of the coolest techniques I have ever seen. Now I realize I actually need to start using AOP instead of just reading about it.

Nice, man.</description>
		<content:encoded><![CDATA[<p>Damn, Alex.his is one of the coolest techniques I have ever seen. Now I realize I actually need to start using AOP instead of just reading about it.</p>
<p>Nice, man.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Reflective Perspective - Chris Alcock &#187; The Morning Brew #69</title>
		<link>http://elegantcode.com/2008/04/08/removing-duplicate-code-in-functions/comment-page-1/#comment-19570</link>
		<dc:creator>Reflective Perspective - Chris Alcock &#187; The Morning Brew #69</dc:creator>
		<pubDate>Wed, 09 Apr 2008 07:22:16 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2008/04/08/removing-duplicate-code-in-functions/#comment-19570</guid>
		<description>[...] Removing Duplicate Code in Functions - Alex Mueller looks at a few techniques (delegates and AOP) for eliminating duplication of code - examples include logging on start and end of functions. [...]</description>
		<content:encoded><![CDATA[<p>[...] Removing Duplicate Code in Functions &#8211; Alex Mueller looks at a few techniques (delegates and AOP) for eliminating duplication of code &#8211; examples include logging on start and end of functions. [...]</p>
]]></content:encoded>
	</item>
</channel>
</rss>
