News Feed
Sections




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

Brandon Savage's Blog:
Peer Review Looking Into Abstraction
August 26, 2009 @ 09:47:31

Brandon Savage has posted his latest article in his series looking at refactoring a piece of code (starting here) focusing in on the abstraction already in the code and how it can be made better.

This article will focus on the constructor method. There are a couple of problems, namely that the constructor itself does a lot of actual work. Also, we have the cURL setup done in the constructor. This object is a Twitter object, not a cURL object; this means that we should decouple the cURL functionality and abstract it into a separate object of its own.

He recommends splitting out the current method the class uses to create the cURL connection (setting it up in the constructor) and making a separate HTTP class that can be pulled in as an object and used as a sort of API. The full code of the new class is also included.

0 comments voice your opinion now!
abstraction review curl refactor


blog comments powered by Disqus

Similar Posts

Slashdot.org: Practical Web 2.0 Applications with PHP

Zend Developer Zone: Learning PHP & MySQL (a Book Review)

PHPBuilder.com: Harness the Scripting Power of PHP and cURL to Update Facebook

Zend Developer Zone: PHP Abstract Podcast Episode 33: Book Review: PHP Web 2.0 Mashup Projects

Michi Kono's Blog: The Best PHP Book Out There


Community Events





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


zendserver deployment interview laravel code language community bugfix development podcast tips series release framework list threedevsandamaybe voicesoftheelephpant introduction symfony api

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