News Feed
Sections




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

Patrick Allaert's Blog:
Readable PHP code #1 - Return ASAP
October 14, 2008 @ 11:14:42

Patrick Allaert has made this recent post to his blog looking at something that a large group of PHP developers seem to forget about - readable PHP code. Specifically, he mentions the "return as soon as possible" mentality.

This is the first article of a series I will dedicate to tips to write PHP code that is easier to maintain, review, refactor,... These tips may be applied for other languages but are mainly focused on PHP. The first one could be entitled as "return as soon as possible.

He compares a code example - simplifying multiple if/elses, replacing the need for multiple nested evaluations that make the code harder to read. Check out the before and after to see how it helps the flow.

0 comments voice your opinion now!
readable return asap refactor ifelse nested


blog comments powered by Disqus

Similar Posts

Dagfinn Reiersol's Blog: Don't refactor without unit tests

NetTuts.com: Refactoring Legacy Code: Part 8 - Inverting Dependencies for a Clean Architecture

Stefan Koopmanschap's Blog: Tip: use clearly readable variable names, and constants!

NetTuts.com: Refactoring Legacy Code: Part 3 - Complex Conditionals

Felix Geisendorfer's Blog: Model::save() now returns an array!


Community Events

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


symfony threedevsandamaybe api version series podcast framework unittest release introduction opinion extension laravel5 community interview laravel security language library voicesoftheelephpant

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