<?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/"
	xmlns:series="http://unfoldingneurons.com/"
		>
<channel>
	<title>Comments on: Peer Review: Looking Into Abstraction</title>
	<atom:link href="http://www.brandonsavage.net/peer-review-looking-into-abstraction/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.brandonsavage.net/peer-review-looking-into-abstraction/</link>
	<description>The personal blog of Brandon Savage. Contains entries of a personal and professional nature focusing on PHP, Apple, LAMP, MySQL and Washington, DC.</description>
	<lastBuildDate>Thu, 29 Jul 2010 11:09:38 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<item>
		<title>By: Brandon Savage</title>
		<link>http://www.brandonsavage.net/peer-review-looking-into-abstraction/#comment-1015</link>
		<dc:creator>Brandon Savage</dc:creator>
		<pubDate>Fri, 28 Aug 2009 15:35:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.brandonsavage.net/?p=571#comment-1015</guid>
		<description>Ray, that&#039;s a very good point. I think that making use of one of the PEAR classes, and/or making use of pecl_http would help resolve that issue and allow for the OOP structure we&#039;re looking for.</description>
		<content:encoded><![CDATA[<p>Ray, that&#8217;s a very good point. I think that making use of one of the PEAR classes, and/or making use of pecl_http would help resolve that issue and allow for the OOP structure we&#8217;re looking for.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ray Paseur</title>
		<link>http://www.brandonsavage.net/peer-review-looking-into-abstraction/#comment-1014</link>
		<dc:creator>Ray Paseur</dc:creator>
		<pubDate>Fri, 28 Aug 2009 15:29:57 +0000</pubDate>
		<guid isPermaLink="false">http://www.brandonsavage.net/?p=571#comment-1014</guid>
		<description>While you can use file_get_contents() if CURL isn&#039;t there, they are not the same things in at least one or two important ways.  CURL will let your request time out.  The file_get_contents() function does not do that.  On my host, file_get_contents() adds its elapsed time to the script execution time with unpleasant results if the remote service is not available.  Splat.</description>
		<content:encoded><![CDATA[<p>While you can use file_get_contents() if CURL isn&#8217;t there, they are not the same things in at least one or two important ways.  CURL will let your request time out.  The file_get_contents() function does not do that.  On my host, file_get_contents() adds its elapsed time to the script execution time with unpleasant results if the remote service is not available.  Splat.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brandon Savage</title>
		<link>http://www.brandonsavage.net/peer-review-looking-into-abstraction/#comment-1005</link>
		<dc:creator>Brandon Savage</dc:creator>
		<pubDate>Wed, 26 Aug 2009 23:23:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.brandonsavage.net/?p=571#comment-1005</guid>
		<description>Daniel, you make a lot of great points. Since the refactoring isn&#039;t finished yet, I&#039;ll be sure to adapt some of your thoughts into the future posts.

I&#039;ll be dropping the &quot;test&quot; stuff in a future post, because testing should be abstracted into unit tests.</description>
		<content:encoded><![CDATA[<p>Daniel, you make a lot of great points. Since the refactoring isn&#8217;t finished yet, I&#8217;ll be sure to adapt some of your thoughts into the future posts.</p>
<p>I&#8217;ll be dropping the &#8220;test&#8221; stuff in a future post, because testing should be abstracted into unit tests.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daniel O'Connor</title>
		<link>http://www.brandonsavage.net/peer-review-looking-into-abstraction/#comment-1004</link>
		<dc:creator>Daniel O'Connor</dc:creator>
		<pubDate>Wed, 26 Aug 2009 23:11:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.brandonsavage.net/?p=571#comment-1004</guid>
		<description>PEAR&#039;s HTTP_Request2, HTTP_Request2_Adapter_Mock and Log can solve your problems kinda neatly here - that way you can kill off all of this test() tomfoolery.

The mock adapter can be pre-armed with faked responses, making your class work exactly the same as it would in production, and all you do is swap the HTTP_Request2 driver from Mock to Real.

The Log object can provide you visibility; outputting to nowhere in production, and whereever you configure in testing.</description>
		<content:encoded><![CDATA[<p>PEAR&#8217;s HTTP_Request2, HTTP_Request2_Adapter_Mock and Log can solve your problems kinda neatly here &#8211; that way you can kill off all of this test() tomfoolery.</p>
<p>The mock adapter can be pre-armed with faked responses, making your class work exactly the same as it would in production, and all you do is swap the HTTP_Request2 driver from Mock to Real.</p>
<p>The Log object can provide you visibility; outputting to nowhere in production, and whereever you configure in testing.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jeff Carouth</title>
		<link>http://www.brandonsavage.net/peer-review-looking-into-abstraction/#comment-1003</link>
		<dc:creator>Jeff Carouth</dc:creator>
		<pubDate>Wed, 26 Aug 2009 20:58:22 +0000</pubDate>
		<guid isPermaLink="false">http://www.brandonsavage.net/?p=571#comment-1003</guid>
		<description>I&#039;ve found it significantly better to lazy load utilities or helpers such as the HTTP object. For example, you can maintain the feel of using a &quot;use once, throw away&quot; object (I assume you meant the HTTPRequest and not the Twitter object) by having a setRequest and getRequest method on the Twitter class.

So, within the getRequest() method if there is not a HTTPRequest object already &quot;injected&quot; then go ahead and instantiate one. This makes it so easy to test in isolation with mocks as Greg mentioned without sacrificing the ease of use you have from your original code.</description>
		<content:encoded><![CDATA[<p>I&#8217;ve found it significantly better to lazy load utilities or helpers such as the HTTP object. For example, you can maintain the feel of using a &#8220;use once, throw away&#8221; object (I assume you meant the HTTPRequest and not the Twitter object) by having a setRequest and getRequest method on the Twitter class.</p>
<p>So, within the getRequest() method if there is not a HTTPRequest object already &#8220;injected&#8221; then go ahead and instantiate one. This makes it so easy to test in isolation with mocks as Greg mentioned without sacrificing the ease of use you have from your original code.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brandon Savage</title>
		<link>http://www.brandonsavage.net/peer-review-looking-into-abstraction/#comment-1002</link>
		<dc:creator>Brandon Savage</dc:creator>
		<pubDate>Wed, 26 Aug 2009 19:52:23 +0000</pubDate>
		<guid isPermaLink="false">http://www.brandonsavage.net/?p=571#comment-1002</guid>
		<description>Greg, you&#039;re absolutely right. This was an oversight, rather than a design goal. I&#039;ll update it in the next blog post when I discuss abstraction in the database layer. Thanks for pointing it out!</description>
		<content:encoded><![CDATA[<p>Greg, you&#8217;re absolutely right. This was an oversight, rather than a design goal. I&#8217;ll update it in the next blog post when I discuss abstraction in the database layer. Thanks for pointing it out!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Greg Beaver</title>
		<link>http://www.brandonsavage.net/peer-review-looking-into-abstraction/#comment-1001</link>
		<dc:creator>Greg Beaver</dc:creator>
		<pubDate>Wed, 26 Aug 2009 19:09:45 +0000</pubDate>
		<guid isPermaLink="false">http://www.brandonsavage.net/?p=571#comment-1001</guid>
		<description>Hi Brandon,

Your refactored example makes the common mistake of using a private method that should be a protected method.  By using protected, you retain all of the benefits of information hiding without preventing any future possibility of extension, or worse, a requirement to cut/paste just to extend.

For instance, your already_tweeted() method uses mysql, but another person might choose to use pgsql.  In order to implement this, our hypothetical person must completely re-implement the tweet() method just to override already_tweeted() which is clearly antithetical to the basic principles of code re-use.

In terms of the HTTP object, it is better to instantiate it in a separate method, one that can be overridden, again for the same reasons as above as well as ease of unit testing in a non-internet-enabled mock twitter environment.</description>
		<content:encoded><![CDATA[<p>Hi Brandon,</p>
<p>Your refactored example makes the common mistake of using a private method that should be a protected method.  By using protected, you retain all of the benefits of information hiding without preventing any future possibility of extension, or worse, a requirement to cut/paste just to extend.</p>
<p>For instance, your already_tweeted() method uses mysql, but another person might choose to use pgsql.  In order to implement this, our hypothetical person must completely re-implement the tweet() method just to override already_tweeted() which is clearly antithetical to the basic principles of code re-use.</p>
<p>In terms of the HTTP object, it is better to instantiate it in a separate method, one that can be overridden, again for the same reasons as above as well as ease of unit testing in a non-internet-enabled mock twitter environment.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brandon Savage</title>
		<link>http://www.brandonsavage.net/peer-review-looking-into-abstraction/#comment-1000</link>
		<dc:creator>Brandon Savage</dc:creator>
		<pubDate>Wed, 26 Aug 2009 16:32:23 +0000</pubDate>
		<guid isPermaLink="false">http://www.brandonsavage.net/?p=571#comment-1000</guid>
		<description>If the object were to be used outside, I might allow it to be injected into the Twitter class. However, because I see it as a &quot;use once, throw away&quot; object, it shouldn&#039;t come from the outside.

If I have an HTTP object that I&#039;m using, and I inject it through the constructor, the changes I make to it will be reflected in any link I have to that object anywhere in my application. By creating a new copy of it, I avoid this problem.

Thoughts?</description>
		<content:encoded><![CDATA[<p>If the object were to be used outside, I might allow it to be injected into the Twitter class. However, because I see it as a &#8220;use once, throw away&#8221; object, it shouldn&#8217;t come from the outside.</p>
<p>If I have an HTTP object that I&#8217;m using, and I inject it through the constructor, the changes I make to it will be reflected in any link I have to that object anywhere in my application. By creating a new copy of it, I avoid this problem.</p>
<p>Thoughts?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jeff Carouth</title>
		<link>http://www.brandonsavage.net/peer-review-looking-into-abstraction/#comment-999</link>
		<dc:creator>Jeff Carouth</dc:creator>
		<pubDate>Wed, 26 Aug 2009 15:45:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.brandonsavage.net/?p=571#comment-999</guid>
		<description>For testing purposes you should remove the instantiation of the HttpRequest object from your constructor. Instead you should inject the HttpRequest object. This decouples your Twitter class from the HttpRequest class. 

Great series!</description>
		<content:encoded><![CDATA[<p>For testing purposes you should remove the instantiation of the HttpRequest object from your constructor. Instead you should inject the HttpRequest object. This decouples your Twitter class from the HttpRequest class. </p>
<p>Great series!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brandon Savage</title>
		<link>http://www.brandonsavage.net/peer-review-looking-into-abstraction/#comment-998</link>
		<dc:creator>Brandon Savage</dc:creator>
		<pubDate>Wed, 26 Aug 2009 12:25:43 +0000</pubDate>
		<guid isPermaLink="false">http://www.brandonsavage.net/?p=571#comment-998</guid>
		<description>You&#039;re absolutely right. This PECL package is stable, and object oriented, which makes it a great option.

For those interested, you can check out the package here:

http://us2.php.net/http</description>
		<content:encoded><![CDATA[<p>You&#8217;re absolutely right. This PECL package is stable, and object oriented, which makes it a great option.</p>
<p>For those interested, you can check out the package here:</p>
<p><a href="http://us2.php.net/http" rel="nofollow">http://us2.php.net/http</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: iwankgb</title>
		<link>http://www.brandonsavage.net/peer-review-looking-into-abstraction/#comment-996</link>
		<dc:creator>iwankgb</dc:creator>
		<pubDate>Wed, 26 Aug 2009 06:50:51 +0000</pubDate>
		<guid isPermaLink="false">http://www.brandonsavage.net/?p=571#comment-996</guid>
		<description>You could use pecl_http package rather the write a wrapper around cURL. It could save you some coding and, being C extension, pecl_http should be more efficient than any PHP wrapper.</description>
		<content:encoded><![CDATA[<p>You could use pecl_http package rather the write a wrapper around cURL. It could save you some coding and, being C extension, pecl_http should be more efficient than any PHP wrapper.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk (feed is rejected)
Page Caching using apc (user agent is rejected)
Database Caching 44/51 queries in 0.000 seconds using disk
Content Delivery Network via Amazon Web Services: S3: files.brandonsavage.net.s3.amazonaws.com

Served from: www.brandonsavage.net @ 2010-07-31 10:48:33 -->