<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Anti-Pattern on Craig Pardey</title>
    <link>https://www.craigpardey.com/tags/anti-pattern/</link>
    <description>Recent content in Anti-Pattern on Craig Pardey</description>
    <generator>Hugo</generator>
    <language>en</language>
    <lastBuildDate>Thu, 19 Jul 2012 00:00:00 +0000</lastBuildDate>
    <atom:link href="https://www.craigpardey.com/tags/anti-pattern/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Anti-pattern: Re-use through inheritance</title>
      <link>https://www.craigpardey.com/post/2012-07-19-anti-pattern-re-use-through-inheritance/</link>
      <pubDate>Thu, 19 Jul 2012 00:00:00 +0000</pubDate>
      <guid>https://www.craigpardey.com/post/2012-07-19-anti-pattern-re-use-through-inheritance/</guid>
      <description>&lt;p&gt;When I first started programming in object oriented languages I used&#xA;inheritance to reduce code duplication. You know the deal - you have two&#xA;classes that do the same sort of thing so you create an abstract superclass&#xA;and extract the common code into methods in the superclass. Voilà. No more&#xA;duplicated code.&lt;/p&gt;&#xA;&lt;p&gt;But I was unwittingly creating an untestable codebase.&lt;/p&gt;&#xA;&lt;p&gt;I have worked extensively with dependency injection containers over the last&#xA;five years and have begun to rely on the clean code they facilitate. DI&#xA;encourages loosely coupled classes and interface abstractions, so code re-use&#xA;is typically achieved by extracting the common code into its own class and&#xA;injecting that class as a collaborator.&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
