<?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 10:05:25 -0500</pubDate>
    <ttl>30</ttl>
    <item>
      <title><![CDATA[Chris Hartjes' Blog: Have a 'Strategy']]></title>
      <guid>http://www.phpdeveloper.org/news/17966</guid>
      <link>http://www.phpdeveloper.org/news/17966</link>
      <description><![CDATA[<p>
In response to <a href="http://odino.org/use-the-strategy-to-avoid-the-switch-case-antipattern/">this suggestion</a> from <i>Alessandro Nadalin</i> about using the "Strategy" design pattern to replace a <a href="http://php.net/switch">switch</a. statement, <i>Chris Hartjes</i> has <a href="http://www.littlehart.net/atthekeyboard/2012/05/15/have-a-strategy/">this new post</a> sharing his opinion of "the right way" do it it.
</p>
<blockquote>
Once I realized what he was doing, I realized that the Strategy pattern was applicable in this case…but his chosen example was dumb and one that I wouldn't have used to demonstrate things. As expected, he told me to supply a sample of a better way. I did, telling him that the sample would be better if he didn't mash the logging level together with the message.
</blockquote>
<p>
Included in the post is sample code, first showing the initial version of the logging class, complete with accompanying tests. Following that, he shows how to refactor it into something using the Strategy pattern, replacing the logging type switch statement with protected methods for each logging message type (critical, notice, etc). 
</p>]]></description>
      <pubDate>Wed, 16 May 2012 10:42:29 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Rafael Dohms' Blog: Book Review: The Art of Readable Code]]></title>
      <guid>http://www.phpdeveloper.org/news/17604</guid>
      <link>http://www.phpdeveloper.org/news/17604</link>
      <description><![CDATA[<p>
<i>Rafael Dohms</i> has posted <a href="http://blog.doh.ms/2012/02/27/book-review-art-of-readable-code/">a new review of a book</a> that focuses on helping you create better, more readable code - "The Art of Readable Code" (<i>Dustin Boswell</i>, <i>Trevor Foucher</i>, O'Reilly). This is isn't about "pretty code" as much as it is manageable, easy to follow structures and logic flows.
</p>
<blockquote>
"The Art of Readable Code" was written by Dustin Bowell and Trevor Foucher and basically focuses on concepts and suggestions to make you code not just readable, but comprehendible by other developers, or as the author's suggest, yourself in six months. Code readability is a topic that I truly believe the PHP community does not focus enough on and i really wanted a look at this book to see what kind of ideas it had and what I could do my best to bring to the attention of other developers.
</blockquote>
<p>
The book is language-agnostic and provides ideas that developers should keep in mind when doing their development - clear variable names, making comments that make sense, refactoring tips and hints for implementing your ideas in code. He recommends the book to any developer (in any language) to help them make code that will stand the test of time and be easier to manage/understand in the future.
</p>]]></description>
      <pubDate>Wed, 29 Feb 2012 10:41:12 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Richard McIntyre's Blog: Using OAuth in Lithium]]></title>
      <guid>http://www.phpdeveloper.org/news/17329</guid>
      <link>http://www.phpdeveloper.org/news/17329</link>
      <description><![CDATA[<p>
<i>Richard McIntyre</i> has a new post to his blog showing how he set up <a href="http://mackstar.com/blog/2011/12/30/using-oauth-lithium">OAuth support in a Lithium-based application</a> with the help of a handy plugin (li3_oath).
</p>
<blockquote>
The <a href="http://oauth.net/">OAuth</a> protocol is a fantastic way to login to remote services and websites. Unfortunately the spec is different in OAuth 1.0 and the yet un-solidified 2.0, the implementation is also different across different services. At the moment this is a bit of a goose chase, but libraries like <a href="https://github.com/gwoo/li3_oauth">li3_oauth</a> can help! [...] I like to be in control and calling the shots! I also want to have users have the option to login to other services under the same umbrella. Working directly with OAuth is what I wanted to do. Of course I was doing this in Lithium because it is clearly the best PHP Framework!
</blockquote>
<p>His process is broken up into four steps:</p>
<ul>
<li>Grab the latest version of the <a href="https://github.com/gwoo/li3_oauth">li3_oauth</a> plugin
<li>Fork and refactor the plugin
<li>Create the Tweet and Facebook controllers
<li>Refactor a bit more to turn it into a service
</ul>
<p>
The code changes are pretty minimal and are included in the post.
</p>]]></description>
      <pubDate>Fri, 30 Dec 2011 13:11:34 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Richard Miller's Blog: Symfony2: Moving Away From the Base Controller]]></title>
      <guid>http://www.phpdeveloper.org/news/16468</guid>
      <link>http://www.phpdeveloper.org/news/16468</link>
      <description><![CDATA[<p>
<i>Richard Miller</i> has a new post to his blog today that recommends <a href="http://miller.limethinking.co.uk/2011/06/14/symfony2-moving-away-from-the-base-controller/">moving away from the base controller</a> the Symfony introductory documentation has you make. He suggests an alternative that can be used more widely.
</p>
<blockquote>
In fact, it is the advised <a href="http://symfony.com/doc/2.0/book/bundles.html#controllers">best practice for controllers in shared bundles</a>. When you do, you will no longer have access to these useful methods, in this post I am going to look at how to accomplish the same tasks without them. I have created a simple controller for some basic form interaction with a model which uses the base controllers methods. I am going to go through how to change this to a service which does not extend the base controller.
</blockquote>
<p>
He starts with his "TestimonialController" that does some of the basic CRUD operations on the testimonial information. He shows you, step-by-step, the refactoring needed to stop using things like the default controller helpers (each with replacement code). With those removed, he can move to extend "ContainerAware" instead of "Controller", make the controller a service and doing some dependency injection for needed resources.
</p>]]></description>
      <pubDate>Tue, 14 Jun 2011 13:23:15 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[James Morris' Blog: Removing Dependencies with the Observer Pattern (SplObserver, SplSubject)]]></title>
      <guid>http://www.phpdeveloper.org/news/16356</guid>
      <link>http://www.phpdeveloper.org/news/16356</link>
      <description><![CDATA[<p>
<i>James Morris</i> has a new post to his blog talking about a way he's found to remove dependencies from parts of your code <a href="http://blog.jmoz.co.uk/removing-dependencies-with-the-observer-patte">by using the Observer pattern</a> (specifically with the SplObserver and SplSubject components of PHP's SPL libraries).
</p>
<blockquote>
Working on a symfony app, you usually have a mix of domain objects that are used by symfony actions, interspersed with symfony specific code such as logging and sfContext type stuff.  A common bad practice I see is symfony specific code peppered inside of domain objects that could be used elsewhere (such as inside of a Zend app or a script from the cli) but now can't as they're coupled to the symfony code. One way you can remove an unwanted dependency is to use the Observer pattern - the dependency is pushed from inside the subject object to the client code that initialises the subject.
</blockquote>
<p>
He sets up a scenario where a symfony action hits a web service and there's a dependency on two other types of objects (a service and transport object). He starts with the code for this method and gradually refactors out those two dependencies, removing an sfContext call from inside the service client and adds attach/detach/notify methods to implement the SplObserver on the class.
</p>]]></description>
      <pubDate>Wed, 18 May 2011 12:05:43 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Lars Strojny's Blog: Dependency Injection Container Refactorings, Part One]]></title>
      <guid>http://www.phpdeveloper.org/news/16223</guid>
      <link>http://www.phpdeveloper.org/news/16223</link>
      <description><![CDATA[<p>
New on his blog today <i>Lars Strojny</i> has posted the <a href="http://usrportage.de/archives/926-Dependency-Injection-Container-Refactorings,-Part-One.html">first part of his look at dependency injection</a> and how he's been using it to do some refactoring in his applications. He uses the Symfony DI container in his examples, but really you can apply the principles to just about any of the other current DI offerings.
</p>
<blockquote>
Working heavily with the Symfony2 Dependency Injection Container, I feel that we found some typical refactorings towards a DI container that emerge during the introduction of such a component. I want to write down the preliminary results of trying to systematize more or less as a draft. I will use the Symfony2 DI container configuration as an example but most of the refactorings should be applicable to other containers as well, some of them even to dependency injection without a container.
</blockquote>
<p>He's broken it up into a few different sections:</p>
<ul>
<li>Making a dependency explicit
<li>Introducing interface injection
<li>Exposing the service
</ul>]]></description>
      <pubDate>Wed, 20 Apr 2011 10:27:12 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Richard McIntyre's Blog: Weaving Lithium #li3 into a legacy PHP application incrementally]]></title>
      <guid>http://www.phpdeveloper.org/news/15581</guid>
      <link>http://www.phpdeveloper.org/news/15581</link>
      <description><![CDATA[<p>
<i>Richard McIntyre</i> has <a href="http://mackstar.com/blog/2010/10/05/weaving-lithium-li3-legacy-php-application-incrementally">posted about his experiences</a> in working the features the <a href="http://lithify.me">Lithium framework</a> into one of his current applications, mostly because of its support for Doctrine and its heavily decoupled nature.
</p>
<blockquote>
I have a legacy application which was originally written in straight PHP with a few classes that I have created for convenience, but this is old and I am wanting to get this into a modern web framework. [...] I wanted to update my site with better validations anyway so I will start with flash messages and then validations. For flash messages in lithium you will need the <a href="http://dev.lithify.me/li3_flash_message">li3_flash_message plugin</a>. 
</blockquote>
<p>
He works through the different parts of the framework setup he needed including a simple bootstrap file and configuring it to use the li_flash_message library. He shows how to use validation rules on submitted data to ensure things like email an link format validity as well as spit back a message for any that are incorrect.
</p>]]></description>
      <pubDate>Wed, 15 Dec 2010 09:18:17 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Jani Hartikainen's Blog: Using unit tests as requirements when refactoring]]></title>
      <guid>http://www.phpdeveloper.org/news/15146</guid>
      <link>http://www.phpdeveloper.org/news/15146</link>
      <description><![CDATA[<p>
<i>Jani Hartikainen</i> has a suggestion for all developers out there who are working through their code and refactoring as they go - make <a href="http://codeutopia.net/blog/2010/09/16/using-unit-tests-as-requirements-when-refactoring/">unit tests a requirement</a> during the process.
</p>
<blockquote>
What should you do to make sure new code works properly when you're refactoring old code? I asked myself this question recently, when I needed to refactor a big bunch of procedural PHP code into a neat, testable, OOP-style interface. The conclusion I came into is that you should write unit tests - not to test the old code, but as requirements for the new code.
</blockquote>
<p>
He suggests setting up a system where unit tests are set up to be where the requests are recorded - a sort of reverse <a href="http://en.wikipedia.org/wiki/Test-driven_development">TDD</a> since you already have code to work with. Even if all of the tests aren't 100% implemented, at least you can run them and see what features you have left to do.
</p>]]></description>
      <pubDate>Fri, 17 Sep 2010 09:33:51 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Wouter Lagerweij's Blog: Reading Up: Books Every Programmer Should Read]]></title>
      <guid>http://www.phpdeveloper.org/news/15047</guid>
      <link>http://www.phpdeveloper.org/news/15047</link>
      <description><![CDATA[<p>
<i>Wouter Lagerweij</i> has posted a list of books he thinks <a href="http://www.lagerweij.com/2010/08/31/reading-up-books-every-programmer-should-read/">every programmer should read</a> to help them get a better handle on their process overall (they apply to any language out there, really).
</p>
<blockquote>
When discussing books on software engineering with colleagues, I got the idea of listing the best books I've read in the past 15 years. Because it seems useful, but also because that will allow others to tell me which ones I should have read.
</blockquote>
<p>
He lists five books that cover some of the "meta" about programming:
</p>
<ul>
<li><a href="http://www.amazon.com/Applying-UML-Patterns-Introduction-Object-Oriented/dp/0131489062">Applying UML patterns</a>
<li><a href="http://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612">Design Patterns - GoF</a>
<li><a href="http://www.amazon.com/Refactoring-Improving-Design-Existing-Code/dp/0201485672">Refactoring (Martin Fowler)</a>
<li><a href="http://www.amazon.com/Test-Driven-Development-Kent-Beck/dp/0321146530">Test-Driven Development (Kent Beck)</a>
<li><a href="http://www.amazon.com/Clean-Code-Handbook-Software-Craftsmanship/dp/0132350882">Clean Code (Robert Martin)</a>
</ul>]]></description>
      <pubDate>Tue, 31 Aug 2010 08:11:04 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Sebastian Bergmann's Blog: PHPUnit 3.5: Refactoring to Components]]></title>
      <guid>http://www.phpdeveloper.org/news/14849</guid>
      <link>http://www.phpdeveloper.org/news/14849</link>
      <description><![CDATA[<p>
In a new post to his blog <i>Sebastian Bergmann</i> talks about <a href="http://sebastian-bergmann.de/archives/892-PHPUnit-3.5-Refactoring-to-Components.html">some updates to PHPUnit</a> that are coming in the 3.5 release.
</p>
<blockquote>
When you look at the list of changes for PHPUnit 3.5, you will see that many of them deal with refactoring to components. Here is an overview of these new components.
</blockquote>
<p>Components that were refactored to work even better include:</p>
<ul>
<li><A href="http://github.com/sebastianbergmann/php-code-coverage">PHP_CodeCoverage</a>
<li><a href="http://github.com/sebastianbergmann/dbunit">DbUnit</a>
<li><a href="http://github.com/sebastianbergmann/phpunit-selenium">PHPUnit_Selenium</a>
<li><a href="http://github.com/sebastianbergmann/phpunit-mock-objects">PUPUnit_MockObject</a>
</ul>]]></description>
      <pubDate>Mon, 26 Jul 2010 11:19:41 -0500</pubDate>
    </item>
  </channel>
</rss>

