<?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>Thu, 24 May 2012 14:35:51 -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>
    <item>
      <title><![CDATA[Freek Lijten's Blog: SOLID - The O is for Open Closed Principle]]></title>
      <guid>http://www.phpdeveloper.org/news/17916</guid>
      <link>http://www.phpdeveloper.org/news/17916</link>
      <description><![CDATA[<p>
<i>Freek Lijten</i> has posted the <a href="http://www.freeklijten.nl/home/2012/05/07/SOLID-the-O-is-for-Open-Closed-Principle">second part</a> of his series looking at the <a href="http://en.wikipedia.org/wiki/SOLID_(object-oriented_design)">SOLID</a> development methodology. In this latest post his looks at the second letter in the acronym - "O" for "Open Closed Principle."
</p>
<blockquote>
Software that requires an enormous amount of changes to implement one new feature or fix a bug is unstable and should be considered as "bad". Software should be designed so, that in case of a new feature, no existing classes should have to change. In other words: it is closed for modification. Existing software may be extended to achieve new features however.
</blockquote>
<p>
He starts off with a "What" section explaining a bit more about what this open/closed means for your code and gets into an example showing it in a more practical way. He shows how to take the principle and refactor an API connector class to pass in the object it needs (Bike) and use that to get information (rather than just passing in the data). He uses a <a href="http://en.wikipedia.org/wiki/Factory_pattern">Factory</a> to get the object type he needs based on the Bike type.
</p>]]></description>
      <pubDate>Mon, 07 May 2012 10:45:37 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Freek Lijten's Blog: SOLID - The S is for Single responsibility]]></title>
      <guid>http://www.phpdeveloper.org/news/17723</guid>
      <link>http://www.phpdeveloper.org/news/17723</link>
      <description><![CDATA[<p>
<i>Freek Lijten</i> has <a href="http://www.freeklijten.nl/home/2012/03/23/SOLID-The-S-is-for-Single-responsibility">written up a new post</a> to his blog about a set of development principles that have been getting more press in the PHP community lately - <a href="http://en.wikipedia.org/wiki/SOLID">SOLID</a>. In his post he starts with a look at the "S" in the set - "Single Responsibility".
</p>
<blockquote>
The single responsibility principle isn't all that hard to explain. It states that an object should do one thing, and one thing only. [...]  A responsibility is a reason to change, and a class should only have one of those. Now all of this may sound abstract and since the objective of this series is to avoid just that we'll just dive into the why now.
</blockquote>
<p>
He includes some sample code to illustrate, going with an active record implementation, some of the problems that come with a typical setup including issues with unit testing, bad practice of using the data store directly, etc. He shows a refactored code example that splits out the functionality previously all in the one class ("Bike") into three different ones - one is the normal Bike object, another compares the Bikes and the third works with the data store to handle the <a href="http://en.wikipedia.org/wiki/Create,_read,_update_and_delete">CRUD</a> for the objects.
</p>]]></description>
      <pubDate>Fri, 23 Mar 2012 11:23:59 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[PHPMaster.com: The Liskov Substitution Principle]]></title>
      <guid>http://www.phpdeveloper.org/news/17442</guid>
      <link>http://www.phpdeveloper.org/news/17442</link>
      <description><![CDATA[<p>
On PHPMaster.com today there's a new post from <i>Alejandro Gervasio</i> about a part of the <a href="http://en.wikipedia.org/wiki/SOLID_(object-oriented_design)">SOLID</a> development methods - the <a href="http://phpmaster.com/liskov-substitution-principle/">Liskov Substitution Principle</a> - the idea that objects should be replaceable with instances of their subtypes without a change to the architecture of the application.
</p>
<blockquote>
Even when the formal definition of the LSP makes eyes roll back (including mine), at its core it boils down to avoiding brittlely-defined class hierarchies where the descendants expose a behavior radically different from the base abstractions consuming the same contract.
</blockquote>
<p>
He includes an example with a "deleted scene" from the Matrix depicting an attempted override of the PDO functionality with a subclass that, unfortunately, does not match the original's structure/method definitions. The problem was in the difference between the method signature for the "query" method. It help resolve situations like this he recommends creating a "contract" in the form of an interface your code can implement, forcing it to conform to a certain structure. Using this, he provides a rewrite of the "PdoAdapter" class to match the original signature 
</p>]]></description>
      <pubDate>Tue, 24 Jan 2012 13:40:35 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Josh Adell's Blog: Command Invoker Pattern with the Open/Closed Principle]]></title>
      <guid>http://www.phpdeveloper.org/news/17398</guid>
      <link>http://www.phpdeveloper.org/news/17398</link>
      <description><![CDATA[<p>
In a response to a <a href="http://phpdeveloper.org/news/17389">recent post</a> on DZone.com about the "Open/Closed Principle" <i>Josh Adell</i> has <a href="http://blog.everymansoftware.com/2012/01/command-invoker-pattern-with-openclosed.html">posted an example</a> of a " flexible and extendable command invocation solution" implementing this <a href="http://en.wikipedia.org/wiki/SOLID_(object-oriented_design)">SOLID</a> idea.
</p>
<blockquote>
Let's overcome some of these issues [with only being able to extend the invoker class and that the invoker needs to know how to create commands], and also make the code even more extensible. I'll use a simplified command invoker to demonstrate.
</blockquote>
<p>
His code is included - the creation of a "Command" interface and two comments that implement it: "HelloCommand" and "PwdCommand", each with "register" and "execute" methods. His "Invoker" class then only needs to be told how to map these commands and the "register" is called as they're needed. You can find the full example code for this invocation example <a href="http://gist.github.com/1610148">in this gist</a>.
</p>]]></description>
      <pubDate>Mon, 16 Jan 2012 10:04:42 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[DZone.com: Open/Closed Principle on real world code]]></title>
      <guid>http://www.phpdeveloper.org/news/17389</guid>
      <link>http://www.phpdeveloper.org/news/17389</link>
      <description><![CDATA[<p>
In a new post to DZone.com <i>Giorgio Sironi</i> talks about the "open/closed principle" in software development and shows an example based on the design of the <a href="https://github.com/giorgiosironi/phpunit-selenium">PHPUnit_Selenium</a> project.
</p>
<blockquote>
This article shows an example of how the application of the Open/Closed Principle improved the design of a real project, the open source library <a href="https://github.com/giorgiosironi/phpunit-selenium">PHPUnit_Selenium</a>. These design concepts apply to every object-oriented language, including Java, Ruby or even C++. The <a href="http://butunclebob.com/ArticleS.UncleBob.PrinciplesOfOod">Open Closed Principle</a>, part of SOLID set, states that software should be open for extension and at the same time closed for modification.
</blockquote>
<p>
He starts with a little background on the project, pointing out that there's a Session object it uses for all of its testing with a magic "__call" method that handles any kind of method call to the object. This method has issues (dependencies, strict requirements for use) but can be refactored according to the Open/Closed idea to set up an array of anonymous functions that can be called as a "command". Examples of these types of classes are also included (one for the "click" action on a button and another for getting the current location).
</p>]]></description>
      <pubDate>Fri, 13 Jan 2012 09:05:53 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Nikita Popov's Blog: Don't be STUPID: GRASP SOLID!]]></title>
      <guid>http://www.phpdeveloper.org/news/17314</guid>
      <link>http://www.phpdeveloper.org/news/17314</link>
      <description><![CDATA[<p>
<i>Nikita Popov</i> talks about the <a href="http://butunclebob.com/ArticleS.UncleBob.PrinciplesOfOod">SOLID</a> coding practices and creates his own acronym for the complete opposite - <a href="http://nikic.github.com/2011/12/27/Dont-be-STUPID-GRASP-SOLID.html">STUPID</a> (Singleon, Tight coupling, Untestable, Premature optimization, Indescriptive naming, Duplication).
</p>
<blockquote>
Ever heard of SOLID code? Probably: It is a term describing a collection of design principles for "good code" that was coined by Robert C. Martin (aka "uncle bob"), our beloved evangelist of clean code. [...] So, why not approach the problem from the other side for once? Looking at what makes up bad code.
</blockquote>
<p>
He goes through each part of his STUPID acronym and talks about how it can hurt your code and a few alternatives to help make your application more flexible and easier to maintain in the long run. He also mentions <a href="http://en.wikipedia.org/wiki/GRASP_%28object-oriented_design%29">GRASP</a> (General Responsibility Assignment Software Principles), another set of good practices to follow, some similar to SOLID, that can make your app better.
</p>]]></description>
      <pubDate>Wed, 28 Dec 2011 09:26:14 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Pim Elshoff's Blog: SOLID design]]></title>
      <guid>http://www.phpdeveloper.org/news/16707</guid>
      <link>http://www.phpdeveloper.org/news/16707</link>
      <description><![CDATA[<p>
In your development time, you might have heard of the SOLID development design principles that aim to keep you and your application well structured and on track. If you haven't had the time to learn much about them, you should consider <a href="http://www.pelshoff.com/2011/08/solid-design">this new post</a> from <i>Pim Elshoff</i> that briefly covers each principle (with some code examples along the way).
</p>
<blockquote>
Oh how we love acronyms. We've discussed a lot about writing a class, but we haven't talked about writing classes yet. How do you know if your solution is right? It is not enough to have a working program. SOLID is a set of principles that define severable measurable properties your architecture should have at least, in order to be dubbed right.&#65279;
</blockquote>
<p>
He goes through each of the principles (single responsibility principle, Liskov substitution principle, etc) and gives a summary statement, a definition and code illustrating it in use. The examples aren't all based on the same code as implementing all of these principles at once as been <a href="http://phpdeveloper.org/news/16431">found</a> to <a href="http://phpdeveloper.org/news/16436">be difficult</a>. He also includes another principle to keep in mind - the "Law of Demeter" dealing with calling scope of properties and methods.
</p>]]></description>
      <pubDate>Thu, 11 Aug 2011 12:15:01 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[DevShed: PHP Object Oriented Programming using LSP]]></title>
      <guid>http://www.phpdeveloper.org/news/16589</guid>
      <link>http://www.phpdeveloper.org/news/16589</link>
      <description><![CDATA[<p>
In another part of their series looking at the <a href="http://en.wikipedia.org/wiki/Solid_(object-oriented_design)">SOLID</a> principles of software development, DevShed focuses again on <a href="http://www.devshed.com/c/a/PHP/PHP-Object-Oriented-Programming-using-LSP/">using LSP</a> (the Liskov Substitution Principle) to help you organize your application (part one is <a href="http://www.devshed.com/c/a/PHP/PHP-Liskov-Substitution-Principle/">here</a>).
</p>
<blockquote>
Even though its formal definition is somewhat hard to grasp, in practical terms it states that methods defined in a base class (or interface) and their derivatives must have the same signature, preconditions should be weakened in the formers, and post-conditions should be strengthened. In addition, if methods in subtypes throw exceptions, they should be of the same type as the ones thrown by the parent abstraction.
</blockquote>
<p>
You'll need to <a href="http://www.devshed.com/c/a/PHP/PHP-Liskov-Substitution-Principle/">read the previous tutorial</a> for things to make sense here. They take off running from there, though and get straight into refactoring the previous example to correct a violation of LSP. In the end you'll have a layout/view system that correctly follows the principles and is pretty simple to use too.
</p>]]></description>
      <pubDate>Thu, 14 Jul 2011 08:57:17 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Zend Developer Zone: Liskov Substitution Principle...attempted]]></title>
      <guid>http://www.phpdeveloper.org/news/16436</guid>
      <link>http://www.phpdeveloper.org/news/16436</link>
      <description><![CDATA[<p>
In <a href="http://phpdeveloper.org/news/16431">a previous post</a> to the Zend Developer Zone <i>Keith Casey</i> talked about the <a href="http://en.wikipedia.org/wiki/Solid_(object-oriented_design)">SOLID</a> principles of software development, a set of guidelines that can help to make software more maintainable and easier to work with. In <a href="http://devzone.zend.com/article/15273-Liskov-Substitution-Principle..-attempted">this new post</a> he looks at the "L" in SOLID, the Liskov Substitution Principle.
</p>
<blockquote>
So the Liskov Substitution Principle boils down to: method/class preconditions cannot be strengthened, method/class post conditions can't be weakened, all exceptions thrown must equally interchangeable and
method signatures should be completely compatible.
</blockquote>
<p>
To help make this all a bit clearer, he includes some code showing a basic class (Rectangle) and how difficult it can be to try to appease all of the principles above without the "fix one, break another" scenario. On comment to the post suggests something that might help things a bit - <a href="http://stackoverflow.com/questions/4019748/programming-by-contracts-in-php">programming by contract</a>.
</p>]]></description>
      <pubDate>Tue, 07 Jun 2011 11:09:41 -0500</pubDate>
    </item>
  </channel>
</rss>

