News Feed
Sections




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

NetTuts.com:
Refactoring Legacy Code Part 3 - Complex Conditionals
May 05, 2014 @ 10:43:20

The NetTuts.com site has posted the third part of their series sharing some tips for refactoring the code in a legacy application. In part one they looked at the "Golden Master" and in part two about moving away from magic strings and constants.

Old code. Ugly code. Complicated code. Spaghetti code. Gibberish nonsense. In two words, Legacy Code. This is a series that will help you work and deal with it. I like to think about code just as I think about prose. Long, nested, composed sentences with exotic words are hard to understand. From time to time you need one, but most of the time, you can just use plain simple words in short sentences. This is very true for source code also.

Continuing on with this "prose" theme, he gives an example of simplification and reducing the amount of validation needed before completing the task. He compares this to complex conditionals and shares something called the "extract method" to help simplify them. He also looks at directory and file structure and suggests cleanup there as well. The tutorial finishes with a few other suggestions, things like cleaning up "runner functions" reworking negative conditionals.

0 comments voice your opinion now!
refactor legacy code series part3 conditionals complex

Link: http://code.tutsplus.com/tutorials/refactoring-legacy-code-part-3-complex-conditionals-long-methods--cms-20944

blog comments powered by Disqus

Similar Posts

Project: RIPS - Static Source Code Analyzer for Vulnerabilities in PHP Scripts

Matthew Weier O'Phinney: Deployment with Zend Server (Part 4 of 8)

PHPMaster.com: Practical Code Refactoring, Part 4 - Efficiency

Yannick Mahe: The Walking Dead: the consequences of living with a legacy PHP framework

Gareth Heyes' Blog: Non alphanumeric code in PHP


Community Events





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


composer language podcast library tool security voicesoftheelephpant version framework symfony interview series package laravel install release update opinion community introduction

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