News Feed
Sections




News Archive
feed this:

Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

NetTuts.com:
Refactoring Legacy Code Part 2 - Magic Strings & Constants
April 03, 2014 @ 12:47:46

NetTuts.com has posted the second part of their "Refactoring Legacy Code" series today continuing on from their beginning of the series. They continue the refactor of their "trivia" application.

Old code. Ugly code. Complicated code. Spaghetti code. Jibberish nonsense. In two words, Legacy Code. This is a series that will help you work and deal with it. We first met our legacy source code in our previous lesson. [...] The time for the first changes have come and what better way to understand a difficult code base than start to extract magic constants and strings into variables? These seemingly simple tasks will give us greater and sometimes unexpected insights into the inner workings of legacy code. We will need to figure out the intentions of the original code author and find the proper names for the pieces of code that we've never seen before.

They talk about refactoring out things like "magic strings" and other hard-coded return values and checks. They mention updating the tests to reflect these changes while keeping an eye out for "magic constants" as well.

0 comments voice your opinion now!
refactoring unittest magic string constant trivia

Link: http://code.tutsplus.com/tutorials/refactoring-legacy-code-part-2-magic-strings-constants--cms-20527

DZone.com:
Trying out PHP Refactoring Browser
April 22, 2013 @ 10:03:35

On DZone.com Giorgio Sironi has written up a post about some testing he's done with the ""PHP Refactoring Browser" (more on that here) on some basic code examples.

IDE proponents love, in fact, an Integrated Development Environment that provides all the functionalities you need while writing and editing code; the followers of the Unix way typically write code in Vim while augmenting it via plugins where feasible and leveraging external tools that do one thing, and do it well. [...] Automated refactorings in PHP were out of the league of Vim and Unix users; thanks to Qafoo, however, a new open source tool is able to edit code with predefined refactoring recipes: PHP Refactoring Browser.

He goes through some of the basic features and functionality of the browser, setting expectations a bit. He shows how to get it installed (via Composer) and the results of some of his testing. Rather than including them all in the post, he opted to make actual commits on github of the changes.

0 comments voice your opinion now!
refactoring browser trial commits github example

Link: http://css.dzone.com/articles/trying-out-php-refactoring

QaFoo.com:
PHP Refactoring Browser Alpha Release
April 08, 2013 @ 09:49:33

On the QaFoo blog today the company is introducing a new tool to help PHP developers write better, more optimized code - the PHP Refactoring Browser (written in PHP too).

Without continuous refactoring, code maintainability and extensibility will start to decrease fast, even if it has tests. Until now, only IDEs contained functionality to perform automated refactorings. And then even only PHPStorm contains the most important refactorings such as "extract method". Today we release the PHP Refactoring Browser, a refactoring tool written completely in PHP. It is based on several outstanding open-source libraries.

The browser currently supports multiple refactoring methods including the extract method, renaming of local variables and converting a local variable to an instance. They include some example code and the result from the execution of the tool. The output shows where refactoring would work best with some color coding and formatting.

You can find more about this new tool over on its github repository.

0 comments voice your opinion now!
refactoring browser tool alpha release components

Link: http://qafoo.com/blog/041_refactoring_browser.html

Brandon Savage:
Effective Refactoring Strategies
December 24, 2012 @ 11:24:57

In a recent post to his site, Brandon Savage has a few helpful hints to keep in mind when you're refactoring your applications to make them easier to maintain (and possibly perform better) in the future.

The downtime [of this week] provides a perfect opportunity for the aspiring software developer to do the one thing they are always told there's no time to do: make the code better for better's sake. With few deadlines and plenty of free time, most developers can get a few hours of refactoring in to their code towards the end of the year. They can rearchitect sections that were implemented with haste in September; they can write tests for sections that were untested in April. Put another way, the "lost week" can be redeemed.

He has a few recommendations, each including their own brief summary:

  • Test Everything First
  • One Method, One Job (Also One Class, One Job)
  • Don't Be Afraid Of More Objects And Classes
  • Remove Dead, Unused, Unnecessary or Old Code
  • Document Your Code

Check out the full post for the summaries and links to other useful resources.

0 comments voice your opinion now!
refactoring tips test single responsibility oop documentation


Marco Tabini's Blog:
The easiest way to add unit test to your application
September 09, 2011 @ 09:17:32

In a new post to his blog Marco Tabini offers some suggestions on unit testing - not really a tutorial on how to it, more of an "easy way in" to introducing it to your development process.

Stopping development for weeks while you figure out how to add unit tests to cover your entire codebase is simply something that cannot be done (at least, not if you want to keep your job), no matter what future benefits it might bring. The good news is, adding unit testing to your existing project only takes five minutes - which is pretty much how long it takes to get a unit testing framework installed. That's it. Move on.

He puts the emphasis on unit testing to manage change in a code base, not so much to ensure that the current application runs as it should (not initially at least). He's found them most useful in bugfixing, refactoring and when adding new functionality. Current tests (and even tests written in TDD) can help with all of these. He includes reminders that if the tests aren't written well, they're useless and that once you've started testing, it needs to be continuous, even if they're not perfect.

0 comments voice your opinion now!
unittest opinion application bugfix improvement refactoring


Devis Lucato's Blog:
Anonymous objects in PHP - Composition, Mocks, Refactoring
November 23, 2010 @ 13:17:53

In a new post to his blog Devis Lucato points out something he noticed when working with objects and anonymous functions/closures - they're not all as they seem.

Both solutions allow to instantiate an anonymous object with properties. They are used as value objects and have no other purpose than storing values, so no logic can be included and they don't come with methods. They can be used as function parameters instead of arrays, for instance. PHP 5.3.0 introduced anonymous functions and closures, so it is now possible to attach functions to these VOs (*). [...] The first thing to notice is that these properties are not methods but callable functions:

In his example, an anonymous function dynamically appended to an object doesn't have access to a property set on the object just one line before. There's a way around it with call_user_func, but it's not practical. His proposed solution is to create a type of Anonymous class that uses the __call method to catch the methods and translate them into calls to call_user_func_array automatically.

0 comments voice your opinion now!
anonymous objects composition mocking refactoring


Jani Hartikainen's Blog:
Refactoring explained to an absolute beginner
June 28, 2010 @ 09:57:52

When developers start graduating from just hacking together scripts and want to start looking toward the future, one thing they start thinking about is making their code the best it could be. One way to achieve this is refactoring, but where to start? Well, this new post has an introductory guide to help developers understand this powerful technique.

Recently while on a drive with a non-programmer friend, I talked with him about code complexity and manageability, how very complicated code is detrimental to productivity and stuff like that. Later on, I decided to explain it to him with actual code examples, although the most he has ever done was some HTML back in elementary school.

He starts with a basic PHP+HTML+MySQL script that mixes the three and shows how to break it apart in steps - moving the PHP away from the HTML, creating functions and making a "template" for the database fetch results to display in.

0 comments voice your opinion now!
refactoring beginner tutorial mysql


Matt Curry's Blog:
Review Refactoring Legacy Applications Using CakePHP
April 09, 2009 @ 11:14:05

Matt Curry has posted his review of the recently released "Refactoring Legacy Applications Using CakePHP" book from Chris Hartjes. The book looks to help developers get a better feel for using CakePHP in real-world applications.

Shortly after Chris Hartjes released his new book Refactoring Legacy Applications Using CakePHP he contacted me and asked if I'd be willing to review it. I jumped at the chance and Chris emailed me the DRM free PDF. After posting it to The PirateBay, I settled in and gave it a read.

Overall, Matt found the content of the book good but had a few things he might change - the "too smooth" nature of the update to CakePHP and the inclusion of a "partial refactoring" section (one that talked about only updating part of an application to the framework and integrating it with the rest of the site).

0 comments voice your opinion now!
refactoring legacy application chrishartjes book review cakephp


Chris Hartjes' Blog:
Preview of "Refactoring Legacy Applications using CakePHP"
January 19, 2009 @ 09:30:26

Chris Hartjes, a guru of CakePHP knowledge, is putting together a book - "Refactoring Legacy Applications Using CakePHP".

Some of you may know that I have started writing a e-book about CakePHP. I'm planning on publishing it myself for the low, low price of $7. I thought I'd let people take a sneak peek at how it looks so far by publishing the first two chapters in very rough form.

You can find a rough draft here (pdf). Keep an eye out on Chris' blog for more (possible) preview releases and for the final product once its wrapped.

0 comments voice your opinion now!
refactoring legacy application cakephp book preview


PHPImpact Blog:
Code Refactoring Guidelines
September 16, 2008 @ 12:16:00

Federico has posted a list of suggestions on things to look out for and to consider when you're refactoring your code.

Refactoring neither fixes bugs nor adds new functionality, though it might precede either activity. Rather it improves the understandability of the code and changes its internal structure and design, and removes dead code, to make it easier to comprehend, more maintainable and amenable to change. Refactoring is usually motivated by the difficulty of adding new functionality to a program or fixing a bug in it.

He's broken it out into a few topics with the suggestions underneath - things like looking at the "Big Picture", avoiding "Extreme Abstraction" and ensuring that your "Error Handling" is up to where it should be.

0 comments voice your opinion now!
refactoring guideline suggestion list



Community Events





Don't see your event here?
Let us know!


series interview introduction security laravel conference opinion release library podcast voicesoftheelephpant composer community version list framework tool artisanfiles language symfony

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework