<?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, 19 Jun 2013 02:52:43 -0500</pubDate>
    <ttl>30</ttl>
    <item>
      <title><![CDATA[Andrew Podner: Make it Testable-No Matter how Painful it is]]></title>
      <guid>http://www.phpdeveloper.org/news/19409</guid>
      <link>http://www.phpdeveloper.org/news/19409</link>
      <description><![CDATA[<p>
In a new post <i>Andrew Podner</i> recommends that, as you're doing your day to day development, you try your hardest to <a href="http://unassumingphp.com/make-it-testable-no-matter-how-painful-it-is/">create testable code</a>, no matter how painful it is.
</p>
<blockquote>
I look at the situation we have gotten into by having this problem [of replacing a large legacy application], and frankly, it is like the tech version of 'Scared Straight'.  The paranoia of such a far reaching application within the enterprise that absolutely has to deploy successfully and also be very flexible to meet the needs of the future have driven me to the point of near madness in trying to make sure this thing is bulletproof, enter Test Driven Development.
</blockquote>
<p>
He includes an example situation he recently was faced with in his code...and opted for the "easy" way out (difficult to test). He talks some about the issues, dependencies and coupled code this has created. He does, however, show a solution to the issue - passing in the dependencies as they're needed, not defining them in the method.
</p>
<blockquote>
For me, writing custom apps in an enterprise environment is not about rapid deployment and looking like a hero.  It is about deploying software with a design life of 7-10 years, because the change management involved in deployment is not something you want be be doing over and over again.  Testable code with 100% coverage of unit tests, well developed integration testing, and prolific use of tools like PHPUnit & Selenium are part of the development culture because while speed is important, durability is even more critical to business. 
</blockquote>
Link: http://unassumingphp.com/make-it-testable-no-matter-how-painful-it-is/]]></description>
      <pubDate>Thu, 04 Apr 2013 09:39:27 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[PHPMaster.com: Preventing Code Rot 101: Unit Testing]]></title>
      <guid>http://www.phpdeveloper.org/news/19253</guid>
      <link>http://www.phpdeveloper.org/news/19253</link>
      <description><![CDATA[<p>
On PHPMaster.com today they've published a new article from <i>Remi Woler</i> about <a href="http://phpmaster.com/preventing-code-rot-101-unit-testing/">preventing "code rot"</a> in your applications through the use of unit testing. He advocates that tests, when applied correctly, can help make refactoring easier and safer, allowing you to change your code and know things stlll work.
</p>
<blockquote>
Unless you're working on a fresh project right now, the codebase you work with most likely has such code you take for granted. And the more challenging your current assignment (or fresh project) is, the more likely it will become a legacy part as well on short notice. Since it's infeasible to fully comprehend all problems that your codebases solve, as well as all their solutions, something else needs to be done to prevent code rot. One way or the other: the code needs to be refactorable to live happily ever after.
</blockquote>
<p>
The breaks down the steps that a unit test should follow on its most base level - assemble the environment to test inside, act on the code and assert that the output was as expected. He walks you through each of these steps, detailing what's involved and including some sample code to illustrate. He also includes a few tips on the successful application of tests like:
</p>
<ul>
<li>Don't forget to write integration/acceptance tests as well.
<li>Name your unit tests verbosely.
<li>Write unit tests for bug fixes.
<li>Never change the code under test.
</ul>]]></description>
      <pubDate>Thu, 28 Feb 2013 13:41:32 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Andrew Podner: Rock On, Refactor, or Re-roll?]]></title>
      <guid>http://www.phpdeveloper.org/news/19249</guid>
      <link>http://www.phpdeveloper.org/news/19249</link>
      <description><![CDATA[<p>
In <a href="http://unassumingphp.com/rock-on-refactor-or-re-roll/">his latest post</a> <i>Andrew Podnet</i> looks at a common situation for developers during one project or another. It's the struggle whether to "rock on" and keep developing a project as it's planned, refactor what's already there into something new or re-roll the whole thing completely, scrapping it for a possibly better structure.
</p>
<blockquote>
I went to my standard code library, developed on my own over a period of 3 or 4 years and starting piecing together a core application that I could start building on.  I worked on this application diligently from June to September, and I would say in that time I had made it 70% of the way through the app.  I was being relatively careful about doing manual functional tests, and I felt good about what I was doing with the application where security practices were concerned.  Then 2 things happened almost simultaneously that really put a wrench in the works.
</blockquote>
<p>
He was working on a project for several months, but due to other circumstances, he had to set it aside for a while. When he came back, he had a new perspective on things and saw lots of places in the code that things could have been done different/better. The post goes through some of his thought process and how it relates to the three "roll on", "refactor" or "re-roll" the current state of the application. He does have a reminder for developers facing the same situation, though:
</p>
<blockquote>
The whole reason I am writing this post, other than to just get my thoughts down and help make the call, is to illustrate the importance of remembering that as developers, one of our key objectives for the client is to deliver value.  This is a fact that can sometimes get away from us.
</blockquote>]]></description>
      <pubDate>Thu, 28 Feb 2013 09:36:44 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Brandon Savage: When To Write Bad Code]]></title>
      <guid>http://www.phpdeveloper.org/news/19105</guid>
      <link>http://www.phpdeveloper.org/news/19105</link>
      <description><![CDATA[<p>
<i>Brandon Savage</i> has posted some of his thoughts on <a href="http://www.brandonsavage.net/when-to-write-bad-code/">when it's okay to write bad code</a> in your development lifecycle:
</p>
<blockquote>
I've been there myself. I recently needed to prototype something. As I sat down to work on it, I had absolutely no idea how I was going to write the component I was working on. And so, I started working - without a plan, without writing tests, without designing an architecture, and without really knowing how the component was going to end up. You know what? The component came out working, but when I was done it was ugly. Totally ugly. The code was bad. But I had a solution, and a solution that worked.
</blockquote>
<p>
He points out that sometimes, doing things "the right way" can stifle creativity and experimentation - two things that a developer needs to solve the problems they face day to day. He notes that refactoring is a part of their job and moving from a rough prototype to a finished product often improves this skill and can find issues not discovered before.  
</p>
<blockquote>
This does NOT mean that developers can push bad code into a repository. Nothing lives longer than temporary code; see to it that your finished code is always good.
</blockquote>]]></description>
      <pubDate>Tue, 29 Jan 2013 11:14:51 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Keith Casey: Refactor vs Rebuild: New Years make New Beginnings]]></title>
      <guid>http://www.phpdeveloper.org/news/19012</guid>
      <link>http://www.phpdeveloper.org/news/19012</link>
      <description><![CDATA[<p>
<i>Keith Casey</i> has an interesting new post to his site looking at a common dilema among development groups - whether <a href="http://caseysoftware.com/blog/refactor-vs-rebuild-new-years-make-new-beginnings">refactor or rewrite</a> is a better option for the state of the current codebase when it comes time for a change.
</p>
<blockquote>
In software development, we're spoiled. We can write a single line of code and do some interesting things. If we add a framework, that single line of code is backed up by thousands.. and can do even more impressive things. [...] I can't tell you how many people have pitched me to "rewite web2project using [framework x]." At first pass, it sounds like a great idea. We can lay the foundation for doing things "right." We can use the latest and greatest tools, technology, and concepts. Even better, we don't have to figure out all that old crappy code! It's open source so it's free anyway. Everyone wins! How many times have you looked at an application and thought "I could rebuild that in a weekend!"
</blockquote>
<p>
He points out the "seductive" nature of this kind of thinking and some of the things that it can hide from your immediate vision. These are things like: the lessons that were learned and implemented in the current code, catch up vs new development on the project and the possibility of "killing the community" as they'd no longer know which part of the project to contribute to.
</p>
<p>
He suggests instead of worrying about a rewrite, that development groups worry more about <a href="http://caseysoftware.com/blog/technical-debt">managing technical debt</a> in their applications and reducing that piece by piece instead.
</p>]]></description>
      <pubDate>Wed, 09 Jan 2013 09:23:31 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[PHPMaster.com: The Single Responsibility Principle]]></title>
      <guid>http://www.phpdeveloper.org/news/18789</guid>
      <link>http://www.phpdeveloper.org/news/18789</link>
      <description><![CDATA[<p>
On PHPMaster.com today <i>Alejandro Gervasio</i> has a new tutorial posted about the <a href="http://phpmaster.com/the-single-responsibility-principle/">Single Responsibility Principle</a> - a guideline that states that each class should only have one "area of concern" and not try to do to much.
</p>
<blockquote>
One of the most notorious consequences of this rational associative process is that, at some point, we effectively end up creating classes that do too much. The so-called "God class" is quite possibly the most extreme and coarse example of a structure that packages literally piles of unrelated operations behind the fence of the same API, but there are other subtle, more furtive situations where assigning of multiple roles to the same class are harder to track down. [...] What the principle attempts to promote is that classes must always be designed to expose only one area of concern and the set of operations they define and implement must be aimed at fulfilling that concern in particular and nothing else.
</blockquote>
<p>
He starts off with a typical violation of the principle, showing a class that not only handles user data but also includes the functions to work with the database directly as well (insert/update/delete). He refactors this into a few much more manageable classes - a mapping class to handle the database interaction and a "User" class representative of a true user object. 
</p>]]></description>
      <pubDate>Thu, 22 Nov 2012 11:58:06 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Adam Culp: Clean Development Series: Part 4, Rewrite dilemma]]></title>
      <guid>http://www.phpdeveloper.org/news/18729</guid>
      <link>http://www.phpdeveloper.org/news/18729</link>
      <description><![CDATA[<p>
<i>Adam Culp</i> has published the <a href="http://www.geekyboy.com/archives/547">fourth part</a> of his "Clean Code" series to his site today (see more about parts 1-3 <a href="http://phpdeveloper.org/news/18704">here</a>) with a look at the "Rewrite Dilema" - whether it's more productive to just rewrite or to try to refactor.
</p>
<blockquote>
Unfortunately the first reaction to a poorly written application is usually a resounding "rewrite".  Developers feel like a weight is lifted from their shoulders, as the manager hears a distant "cha-ching" sounds of money slipping away. [...] In the managers mind a rewrite means it must all be duplicated, and that's not far from the truth when we consider the salaries of an entire development team for the time it will take to rewrite the entire application.
</blockquote>
<p>
<i>Adam</i> talks about some of his experience in the past with challenging applications and a typical scenario where one group in the company splits off and creates the new version while another maintains the old. He suggests, however, that refactoring may be a more viable option. While it might not seem easier to handle overall, the end results could lead to a more stable system and could take less time than starting from scratch.
</p>]]></description>
      <pubDate>Mon, 12 Nov 2012 10:28:30 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Oscar Merida: Smelly PHP code]]></title>
      <guid>http://www.phpdeveloper.org/news/18720</guid>
      <link>http://www.phpdeveloper.org/news/18720</link>
      <description><![CDATA[<p>
<i>Oscar Merida</i> has written up a <a href="http://oscarm.org/2012/11/smelly-php-code">sort of continuation</a> to <a href="http://phpdeveloper.org/news/18704">this series</a> from <i>Adam Culp</i> about clean code, one that shares more tips on knowing when to refctor.
</p>
<blockquote>
Adam Culp posted the 3rd article in his Clean Development Series this week, <a href="http://www.geekyboy.com/archives/494">Dirty Code (how to spot/smell it)</a>. When you read it, you should keep in mind that he is pointing out practices which correlate with poorly written code not prescribing a list of things to avoid. It's a good list of things to look for and engendered quite a discussion in our internal <a href="http://musketeers.me/">Musketeers</a> IRC.
</blockquote>
<p>
His suggestions include things like "Comments are valuable", "Using switch statements" and a few other smaller ones involving error suppression, globals and prepared statements in database usage.
</p>]]></description>
      <pubDate>Fri, 09 Nov 2012 09:21:57 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[PHPMaster.com: Practical Code Refactoring, Part 4 - Efficiency]]></title>
      <guid>http://www.phpdeveloper.org/news/18684</guid>
      <link>http://www.phpdeveloper.org/news/18684</link>
      <description><![CDATA[<p>
PHPMaster.com has posted the latest in their "Practical Code Refactoring" series , this time with a <a href="http://phpmaster.com/practical-code-refactoring-4/">focus on efficiency</a> and how you can refactor your code to help it perform better both in processing power and in resource use.
</p>
<blockquote>
In <a href="http://phpmaster.com/practical-code-refactoring-3/">part three</a> of this series we dealt with refactoring code for extensibility and discussed logical extensibility, modular design, decoupling, and encapsulation. In this final part of the series, we discuss what the main concerns of efficiency are for your web application and how to refactor for better efficiency.
</blockquote>
<p>
They talk about some of the things you can do about network bandwidth usage, memory inefficiencies and processing issues (over you doing more work than you need to?). These aren't code examples - every application is different when it comes to this stuff, but it gives you some good questions to ask to fill in the blanks.
</p>]]></description>
      <pubDate>Thu, 01 Nov 2012 11:37:54 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[PHPMaster.com: Practical Code Refactoring, Part 3 - Extensibility]]></title>
      <guid>http://www.phpdeveloper.org/news/18655</guid>
      <link>http://www.phpdeveloper.org/news/18655</link>
      <description><![CDATA[<p>
PHPMaster.com has posted the third part in their "Practical Code Refactoring" series - this time with a <a href="http://phpmaster.com/practical-code-refactoring-3/">focus on Extensibility</a>. (<a href="http://phpmaster.com/practical-refactoring-1/">Part 1</a>, <a href="http://phpmaster.com/practical-code-refactoring-2/">Part 2</a>).
</p>
<blockquote>
Extensible code is a piece of code which follows re-usable, logical, well-known patterns, be it standard design patterns, or normal logical flow. Modular code tends to be highly extensible and monolithic code tends to be non-extensible, but monolithic code might be more efficient, so to solve this conundrum some practices allow developing in a modular way and deploying in a monolithic way so we can get the best of both worlds. The major aspects which we are to discuss with regard to extensible code are: logical extensibility (normal logical flow and design patterns), modular design, and decoupling and encapsulation.
</blockquote>
<p>
He goes through each of the sections - logical extensibility, modular design and decoupling/encapsulation - and for each provides some questions to ask to help you whip your code into shape.
</p>]]></description>
      <pubDate>Thu, 25 Oct 2012 09:22:05 -0500</pubDate>
    </item>
  </channel>
</rss>
