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:
Why Interfaces Rock
September 25, 2009 @ 09:11:32

According to the latest post on his blog Brandon Savage thinks interfaces rock:

When I first learned PHP 5's object oriented syntax and rules, I didn't see much of a point to the interface options. I felt that I could do more by defining abstract classes and at least filling in some of the methods with some details. [...] As a developer, I've often wished there was a way to know that an object - any object - had implemented certain methods. With type hinting and the instanceof operator, it is now possible to determine whether or not an object has those methods, and interfaces make this even easier.

He includes an example or two of how type hinting can help you enforce and predict what sort of methods are defined in other classes. He also points out that this can be one of the major drawbacks of interfaces as well - because they are so strict, they have to be adhered to exactly.

0 comments voice your opinion now!
interface abstract class opinon


blog comments powered by Disqus

Similar Posts

Stubbles Blog: Lazy loading of classes stored in a session without __autoload()

Juozas Kaziukenas' Blog: SQL Native Client as MSSQL driver for Zend Framework

Elizabeth Smith's Blog: CC_Tooltips - easy php-gtk tooltip management

DevShed: Effects of Wrapping Code in Class Constructs

Juozas Kaziukenas' Blog: Debugging with FirePHP and Firebug


Community Events





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


language unittest release configure api interview code list podcast laravel wordpress install series community introduction application threedevsandamaybe developer bugfix framework

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