<?xml version="1.0"?>
<rss version="2.0">
  <channel>
    <title>PHPDeveloper.org</title>
    <link>http://www.phpdeveloper.org</link>
    <description>Up-to-the Minute PHP News, views and community</description>
    <language>en-us</language>
    <pubDate>Wed, 22 May 2013 21:54:43 -0500</pubDate>
    <ttl>30</ttl>
    <item>
      <title><![CDATA[PHPMaster.com: The Dependency Inversion Principle]]></title>
      <guid>http://www.phpdeveloper.org/news/17938</guid>
      <link>http://www.phpdeveloper.org/news/17938</link>
      <description><![CDATA[<p>
Continuing on in their series looking at the <a href="http://en.wikipedia.org/wiki/SOLID_(object-oriented_design)">SOLID</a> development principles, <i>Alejandro Gervasio </i> picks back up and looks at the "D" in the set - the <a href="http://phpmaster.com/dip-intro/">dependency inversion principle</a>.
</p>
<blockquote>
While some central concepts in the realm of object-oriented design are generally harder to digest at first, such as separation of concerns and implementation switching, more intuitive and untangled paradigms on the other hand are simpler, like programming to interfaces. Unfortunately, the DIP's formal definition is surrounded by a double-edged curse/blessing that often makes programmers gloss over it, as in many cases there's an implicit assumption that the principle is nothing but a fancy expression for the aforementioned "programming to interfaces" commandment.
</blockquote>
<p>
He talks about how decoupling your code and working against interfaces is only part of the equation. The other half is the actual "inversion" part of the process - the ownership that the high-level modules must have over the abstractions. He illustrates with an example, a storage module that is highly dependent on a Serializer. Using the DIP principle, he turns this around and refactors his storage class to take in an Encoder object as a part of its construction. Complete source for both versions is included.
</p>]]></description>
      <pubDate>Thu, 10 May 2012 08:52:19 -0500</pubDate>
    </item>
  </channel>
</rss>
