<?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://organizeseries.com/"
		>
<channel>
	<title>Comments on: Interfaces or Abstract Classes?</title>
	<atom:link href="http://www.brandonsavage.net/interfaces-or-abstract-classes/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.brandonsavage.net/interfaces-or-abstract-classes/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=interfaces-or-abstract-classes</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>Wed, 15 May 2013 14:54:51 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.2-alpha</generator>
	<item>
		<title>By: Jon</title>
		<link>http://www.brandonsavage.net/interfaces-or-abstract-classes/#comment-12247</link>
		<dc:creator>Jon</dc:creator>
		<pubDate>Wed, 03 Apr 2013 21:02:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.brandonsavage.net/?p=2204#comment-12247</guid>
		<description><![CDATA[Java 1.8 , as part of the Lambda package, is going to allow what is called &quot;Defender methods&quot; capability, which allows you to have a default implmentation of a method completely defined in a interface definition, thereby enabling the inheritance of multiple interfaces without the requirement of having to define what those methods do unless you want to re-define them (different than a override).]]></description>
		<content:encoded><![CDATA[<p>Java 1.8 , as part of the Lambda package, is going to allow what is called &#8220;Defender methods&#8221; capability, which allows you to have a default implmentation of a method completely defined in a interface definition, thereby enabling the inheritance of multiple interfaces without the requirement of having to define what those methods do unless you want to re-define them (different than a override).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stephen S. Musoke</title>
		<link>http://www.brandonsavage.net/interfaces-or-abstract-classes/#comment-7569</link>
		<dc:creator>Stephen S. Musoke</dc:creator>
		<pubDate>Mon, 25 Feb 2013 14:04:36 +0000</pubDate>
		<guid isPermaLink="false">http://www.brandonsavage.net/?p=2204#comment-7569</guid>
		<description><![CDATA[Interfaces are a contract for behavior - any class that implements an interface must provide an implementation for the methods in the interface. 

Abstract classes - form a basic building block with common behavior for a hierarchy of classes and can force child classes to enforce certain behavior

Interfaces are great for grouping related behavior and can be used across a complete codebase while Abstract classes are only good for behavior in a specific hierarchy of objects. 

A good mix would be to define interfaces and have base Abstract classes for specific hierarchies]]></description>
		<content:encoded><![CDATA[<p>Interfaces are a contract for behavior &#8211; any class that implements an interface must provide an implementation for the methods in the interface. </p>
<p>Abstract classes &#8211; form a basic building block with common behavior for a hierarchy of classes and can force child classes to enforce certain behavior</p>
<p>Interfaces are great for grouping related behavior and can be used across a complete codebase while Abstract classes are only good for behavior in a specific hierarchy of objects. </p>
<p>A good mix would be to define interfaces and have base Abstract classes for specific hierarchies</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Evert</title>
		<link>http://www.brandonsavage.net/interfaces-or-abstract-classes/#comment-7514</link>
		<dc:creator>Evert</dc:creator>
		<pubDate>Fri, 22 Feb 2013 22:42:44 +0000</pubDate>
		<guid isPermaLink="false">http://www.brandonsavage.net/?p=2204#comment-7514</guid>
		<description><![CDATA[It could make sense, but you&#039;ll find OOP and design pattern-purist mostly typing on interfaces at all time, because they are more flexible, and other reasons.

I&#039;m not a purist though, I am a pragmatist and I try to use the best tool for the job.. 

I find in the project I work on (a relatively large and complex open source library, been at it for 6 years now) that slowly the places where I made a decision earlier to use (abstract-)classes as the base type, I&#039;m shifting towards interfaces.

So generally I disagree, in most cases where I need to spend the most time on quality, durability and backwards compatibility (public, open source code basically), type is in 90% of the cases provided by some interface, and implementation by classes.

I feel very different about private code though, and maintain very different design goals for code where both the API and the consumer is controlled, for example within the same company. In those cases I try to work as &#039;flat&#039; as possible, use inheritance sparingly and interfaces almost never. For private code I my primary goal is to write code that extremely easy to refactor, throw away or rewrite.]]></description>
		<content:encoded><![CDATA[<p>It could make sense, but you&#8217;ll find OOP and design pattern-purist mostly typing on interfaces at all time, because they are more flexible, and other reasons.</p>
<p>I&#8217;m not a purist though, I am a pragmatist and I try to use the best tool for the job.. </p>
<p>I find in the project I work on (a relatively large and complex open source library, been at it for 6 years now) that slowly the places where I made a decision earlier to use (abstract-)classes as the base type, I&#8217;m shifting towards interfaces.</p>
<p>So generally I disagree, in most cases where I need to spend the most time on quality, durability and backwards compatibility (public, open source code basically), type is in 90% of the cases provided by some interface, and implementation by classes.</p>
<p>I feel very different about private code though, and maintain very different design goals for code where both the API and the consumer is controlled, for example within the same company. In those cases I try to work as &#8216;flat&#8217; as possible, use inheritance sparingly and interfaces almost never. For private code I my primary goal is to write code that extremely easy to refactor, throw away or rewrite.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Paul</title>
		<link>http://www.brandonsavage.net/interfaces-or-abstract-classes/#comment-7494</link>
		<dc:creator>Paul</dc:creator>
		<pubDate>Fri, 22 Feb 2013 10:23:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.brandonsavage.net/?p=2204#comment-7494</guid>
		<description><![CDATA[@Evert, I get your point. Yes, interfaces can define types, but from the client&#039;s point of view. I like to see it like this: objects have a type that is purely defined by their class and their superclasses. If they fulfill some contract used by other objects, they can express this by implementing an interface. However, this does not change the object&#039;s type, but states that the object _also_ acts as an implementation of the contract declared by that interface. Does that make sense to you?

Cheers,
  Paul]]></description>
		<content:encoded><![CDATA[<p>@Evert, I get your point. Yes, interfaces can define types, but from the client&#8217;s point of view. I like to see it like this: objects have a type that is purely defined by their class and their superclasses. If they fulfill some contract used by other objects, they can express this by implementing an interface. However, this does not change the object&#8217;s type, but states that the object _also_ acts as an implementation of the contract declared by that interface. Does that make sense to you?</p>
<p>Cheers,<br />
  Paul</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Wayne</title>
		<link>http://www.brandonsavage.net/interfaces-or-abstract-classes/#comment-7457</link>
		<dc:creator>Wayne</dc:creator>
		<pubDate>Thu, 21 Feb 2013 18:57:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.brandonsavage.net/?p=2204#comment-7457</guid>
		<description><![CDATA[This is a pretty good writeup.  I did a comparison of Interfaces an Abstract Classes about a year ago.  http://waynemay.com/interfaces-vs-abstract-classes-in-php/]]></description>
		<content:encoded><![CDATA[<p>This is a pretty good writeup.  I did a comparison of Interfaces an Abstract Classes about a year ago.  <a href="http://waynemay.com/interfaces-vs-abstract-classes-in-php/" rel="nofollow">http://waynemay.com/interfaces-vs-abstract-classes-in-php/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Evert</title>
		<link>http://www.brandonsavage.net/interfaces-or-abstract-classes/#comment-7454</link>
		<dc:creator>Evert</dc:creator>
		<pubDate>Thu, 21 Feb 2013 15:47:05 +0000</pubDate>
		<guid isPermaLink="false">http://www.brandonsavage.net/?p=2204#comment-7454</guid>
		<description><![CDATA[I disagree that interfaces don&#039;t provide &#039;type&#039;. I use that concept everywhere, and generally only force type based on interface. If I combine that with traits I can effectively achieve what multiple inheritance also provides. But I agree that it&#039;s not _exactly_ the same thing on a language-level.

As with all of these abstract concepts it&#039;s subjective though. To me, with the design problems I am facing, I can achieve a form of multiple inheritence, which is kinda where I&#039;m coming from.]]></description>
		<content:encoded><![CDATA[<p>I disagree that interfaces don&#8217;t provide &#8216;type&#8217;. I use that concept everywhere, and generally only force type based on interface. If I combine that with traits I can effectively achieve what multiple inheritance also provides. But I agree that it&#8217;s not _exactly_ the same thing on a language-level.</p>
<p>As with all of these abstract concepts it&#8217;s subjective though. To me, with the design problems I am facing, I can achieve a form of multiple inheritence, which is kinda where I&#8217;m coming from.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anthony</title>
		<link>http://www.brandonsavage.net/interfaces-or-abstract-classes/#comment-7453</link>
		<dc:creator>Anthony</dc:creator>
		<pubDate>Thu, 21 Feb 2013 14:59:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.brandonsavage.net/?p=2204#comment-7453</guid>
		<description><![CDATA[Evert,

Traits are not multiple inheritance. And neither are interfaces. 

Inheritance requires the ability to overload methods. Traits do not provide that ability. Additionally, inheritance is also about typing, something that traits by very definition do not provide.  Inheritance provides sub-type polymorphism. Traits have no mechanisms for that. Traits are nothing more (literally) than compiler-aided copy/paste. Inheritance is much more than just copy/paste.

Interfaces only provide a contract, they do not define a &quot;type&quot;.  Therefore, interfaces do not provide sub-type polymorphism. They are very useful for providing polymorphic behavior, but they are a very different concept than inheritance. 

It&#039;s a very subtle difference mind you. In practice you can use traits and interfaces to simulate multiple inheritance. But it&#039;s not multiple inheritance. And I think it&#039;s very important to draw that distinction so that we communicate clearly. Traits have a very specific contract with the developer. They are not intended to provide polymorphism or typing. They are intended for static (compile-time) horizontal code re-use only.  

My $0.02 at least...]]></description>
		<content:encoded><![CDATA[<p>Evert,</p>
<p>Traits are not multiple inheritance. And neither are interfaces. </p>
<p>Inheritance requires the ability to overload methods. Traits do not provide that ability. Additionally, inheritance is also about typing, something that traits by very definition do not provide.  Inheritance provides sub-type polymorphism. Traits have no mechanisms for that. Traits are nothing more (literally) than compiler-aided copy/paste. Inheritance is much more than just copy/paste.</p>
<p>Interfaces only provide a contract, they do not define a &#8220;type&#8221;.  Therefore, interfaces do not provide sub-type polymorphism. They are very useful for providing polymorphic behavior, but they are a very different concept than inheritance. </p>
<p>It&#8217;s a very subtle difference mind you. In practice you can use traits and interfaces to simulate multiple inheritance. But it&#8217;s not multiple inheritance. And I think it&#8217;s very important to draw that distinction so that we communicate clearly. Traits have a very specific contract with the developer. They are not intended to provide polymorphism or typing. They are intended for static (compile-time) horizontal code re-use only.  </p>
<p>My $0.02 at least&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Milan Popović</title>
		<link>http://www.brandonsavage.net/interfaces-or-abstract-classes/#comment-7452</link>
		<dc:creator>Milan Popović</dc:creator>
		<pubDate>Thu, 21 Feb 2013 14:42:55 +0000</pubDate>
		<guid isPermaLink="false">http://www.brandonsavage.net/?p=2204#comment-7452</guid>
		<description><![CDATA[Why don&#039;t you want to define concrete methods in abstract classes?]]></description>
		<content:encoded><![CDATA[<p>Why don&#8217;t you want to define concrete methods in abstract classes?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Paul</title>
		<link>http://www.brandonsavage.net/interfaces-or-abstract-classes/#comment-7448</link>
		<dc:creator>Paul</dc:creator>
		<pubDate>Thu, 21 Feb 2013 13:57:08 +0000</pubDate>
		<guid isPermaLink="false">http://www.brandonsavage.net/?p=2204#comment-7448</guid>
		<description><![CDATA[I think that you can&#039;t really compare interfaces with abstract classes since they have completely different meanings. An abstract class describes an abstract super-type - an interface only a set of methods that client objects might want to use. People should start using inheritance for sub-typing instead of for making functionality of other classes available in an object. This is what traits and composition are for...]]></description>
		<content:encoded><![CDATA[<p>I think that you can&#8217;t really compare interfaces with abstract classes since they have completely different meanings. An abstract class describes an abstract super-type &#8211; an interface only a set of methods that client objects might want to use. People should start using inheritance for sub-typing instead of for making functionality of other classes available in an object. This is what traits and composition are for&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Evert</title>
		<link>http://www.brandonsavage.net/interfaces-or-abstract-classes/#comment-7446</link>
		<dc:creator>Evert</dc:creator>
		<pubDate>Thu, 21 Feb 2013 13:08:51 +0000</pubDate>
		<guid isPermaLink="false">http://www.brandonsavage.net/?p=2204#comment-7446</guid>
		<description><![CDATA[I&#039;d argue that traits + interfaces is a form of multiple inheritance.]]></description>
		<content:encoded><![CDATA[<p>I&#8217;d argue that traits + interfaces is a form of multiple inheritance.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic (Feed is rejected)
Page Caching using disk: enhanced (User agent is rejected)
Object Caching 587/605 objects using apc
Content Delivery Network via Amazon Web Services: S3: brandonsavage-net-files.s3.amazonaws.com

 Served from: www.brandonsavage.net @ 2013-05-22 13:41:17 by W3 Total Cache -->