<?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: What Interfaces Are For</title>
	<atom:link href="http://www.brandonsavage.net/what-interfaces-are-for/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.brandonsavage.net/what-interfaces-are-for/</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/what-interfaces-are-for/#comment-1547</link>
		<dc:creator>Brandon Savage</dc:creator>
		<pubDate>Sat, 10 Oct 2009 21:36:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.brandonsavage.net/?p=854#comment-1547</guid>
		<description>This has been fixed.</description>
		<content:encoded><![CDATA[<p>This has been fixed.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chuck Burgess</title>
		<link>http://www.brandonsavage.net/what-interfaces-are-for/#comment-1512</link>
		<dc:creator>Chuck Burgess</dc:creator>
		<pubDate>Wed, 07 Oct 2009 14:53:59 +0000</pubDate>
		<guid isPermaLink="false">http://www.brandonsavage.net/?p=854#comment-1512</guid>
		<description>I second Greg&#039;s point, as it fits right into the &quot;program to an interface&quot; mantra.  By &quot;hiding&quot; your class hierarchy behind your interfaces, users of your code need only ever know about the interfaces themselves.  If they program directly to said interfaces rather than attempting to use your classes directly, both they and you are insulated from being affected by you changing/refactoring your classes.</description>
		<content:encoded><![CDATA[<p>I second Greg&#8217;s point, as it fits right into the &#8220;program to an interface&#8221; mantra.  By &#8220;hiding&#8221; your class hierarchy behind your interfaces, users of your code need only ever know about the interfaces themselves.  If they program directly to said interfaces rather than attempting to use your classes directly, both they and you are insulated from being affected by you changing/refactoring your classes.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Greg Beaver</title>
		<link>http://www.brandonsavage.net/what-interfaces-are-for/#comment-1511</link>
		<dc:creator>Greg Beaver</dc:creator>
		<pubDate>Wed, 07 Oct 2009 14:10:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.brandonsavage.net/?p=854#comment-1511</guid>
		<description>Although the documenting of a public API is often given as the reason for interfaces, I don&#039;t think that is what makes them useful.  Their utility lies in the ability to allow substitution of a different implementation that implements the same public API.  It is in this flexibility that the power of interfaces lie.  They can be used to prevent an annoying &quot;method not found&quot; fatal error, while providing flexibility to specify multiple implementations of the same public API.

This can be used to approximate multiple inheritance.  For instance, this code:



Allows taking advantage of SPL&#039;s UnexpectedValueException while also allowing users to perform a catch-all:



or a more fine-grained approach:



This essentially mimics something like the hypothetical:



Using an interface for a class that is a base class with no intention of allowing implementation switching makes little sense, as type hints can simply use the base class.</description>
		<content:encoded><![CDATA[<p>Although the documenting of a public API is often given as the reason for interfaces, I don&#8217;t think that is what makes them useful.  Their utility lies in the ability to allow substitution of a different implementation that implements the same public API.  It is in this flexibility that the power of interfaces lie.  They can be used to prevent an annoying &#8220;method not found&#8221; fatal error, while providing flexibility to specify multiple implementations of the same public API.</p>
<p>This can be used to approximate multiple inheritance.  For instance, this code:</p>
<p>Allows taking advantage of SPL&#8217;s UnexpectedValueException while also allowing users to perform a catch-all:</p>
<p>or a more fine-grained approach:</p>
<p>This essentially mimics something like the hypothetical:</p>
<p>Using an interface for a class that is a base class with no intention of allowing implementation switching makes little sense, as type hints can simply use the base class.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Russ</title>
		<link>http://www.brandonsavage.net/what-interfaces-are-for/#comment-1509</link>
		<dc:creator>Russ</dc:creator>
		<pubDate>Wed, 07 Oct 2009 10:10:44 +0000</pubDate>
		<guid isPermaLink="false">http://www.brandonsavage.net/?p=854#comment-1509</guid>
		<description>It&#039;s probably worth noting for those that aren&#039;t aware of it, that an object created with a class that extends an interface will be an &quot;instance of&quot; that interface.

This is extremely useful when coding &quot;higher up&quot; because once you&#039;ve checked if ($myObject instanceof coolInterface) you can be sure that you have access to all the methods that interface defines.

This is of course very useful when we talk about standard interfaces too - like testing if an object implements ArrayAccess for example.

I also find that working in a large team, interfaces can be part of a design. Once I made an interface purely so another developer could &quot;code to it&quot;. I could continue with my work knowing that the class he was creating would satisfy all my needs.</description>
		<content:encoded><![CDATA[<p>It&#8217;s probably worth noting for those that aren&#8217;t aware of it, that an object created with a class that extends an interface will be an &#8220;instance of&#8221; that interface.</p>
<p>This is extremely useful when coding &#8220;higher up&#8221; because once you&#8217;ve checked if ($myObject instanceof coolInterface) you can be sure that you have access to all the methods that interface defines.</p>
<p>This is of course very useful when we talk about standard interfaces too &#8211; like testing if an object implements ArrayAccess for example.</p>
<p>I also find that working in a large team, interfaces can be part of a design. Once I made an interface purely so another developer could &#8220;code to it&#8221;. I could continue with my work knowing that the class he was creating would satisfy all my needs.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Miro</title>
		<link>http://www.brandonsavage.net/what-interfaces-are-for/#comment-1505</link>
		<dc:creator>Miro</dc:creator>
		<pubDate>Wed, 07 Oct 2009 08:10:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.brandonsavage.net/?p=854#comment-1505</guid>
		<description>Just a technical note, you have a single quote instead of a double quote in your HTML markup near ...You may define interface is for defining your public API... which corrupts the rendering.</description>
		<content:encoded><![CDATA[<p>Just a technical note, you have a single quote instead of a double quote in your HTML markup near &#8230;You may define interface is for defining your public API&#8230; which corrupts the rendering.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stephan Hochdoerfer</title>
		<link>http://www.brandonsavage.net/what-interfaces-are-for/#comment-1503</link>
		<dc:creator>Stephan Hochdoerfer</dc:creator>
		<pubDate>Wed, 07 Oct 2009 06:59:57 +0000</pubDate>
		<guid isPermaLink="false">http://www.brandonsavage.net/?p=854#comment-1503</guid>
		<description>In addition to that the usage of interfaces make the code easier to test. Instead of relying on a certain base class your code relies on an interfaces which do not rely on other classes (at least if you got your API design right).</description>
		<content:encoded><![CDATA[<p>In addition to that the usage of interfaces make the code easier to test. Instead of relying on a certain base class your code relies on an interfaces which do not rely on other classes (at least if you got your API design right).</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.010 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 11:06:15 -->