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 #2 - Make your API handle more!
May 28, 2010 @ 08:41:22

In a new post today Patrick Allaert has continued his "Readable Code" series with some tips on how you can make your API handle more.

His suggestions include:

  • Changing the handling to look for multiples by default
  • Avoiding inner looping (repeated looping) and try for code reuse
  • Transforming a scalar value into an array to make it easier to handle this way (by casting)
  • and how to handle objects in the same array-handling kind of code

He also tosses in a little mention of performance, noting that a call with range in the argument to his array-handling method is faster than looping over the same range and calling the method each time.

0 comments voice your opinion now!
readable api handle array object scalar tip


blog comments powered by Disqus

Similar Posts

Zend Developer Zone: Mobile Platforms Built On Object-Oriented PHP 5

Alexey Zakhlestin's Blog: Syck 0.9.2

Jani Hartikainen's Blog: Decoupling models from the database: Data Access Object pattern in PHP

Ibuildings techPortal: DPC Radio: Keynote - First Class APIs

Jani Hartikainen's Blog: What is a null object, and when are they useful?


Community Events

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


conference series composer symfony2 example release api opinion configure introduction library podcast framework voicesoftheelephpant community interview laravel php7 performance application

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