News Feed
Sections




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

RubySource.com:
PHP to Ruby Modules, Mixins and Ducks
August 16, 2011 @ 09:11:35

In his latest article comparing some of the functionality of PHP to Ruby, Dave Kennedy looks at modules, mixins and ducks and how they compare to PHP's interfaces and abstract classes.

If you have been writing PHP for a few years you will no doubt have come across Interfaces and Abstract classes. They were introduced in PHP5 object model and since have had medium usage in the PHP world. If you Google "PHP Interfaces" you will get some results on the official documentation and the rest saying how pointless they are. Why the divide? I believe it is mainly down to lack of understanding to what interfaces give you. They imply what your classes should do, but that's it. Yep, we are talking programming contracts.

He starts with some code examples of an interface and a class that implements it (to work with PDFs). He makes an abstract class to extend the functionality even further and allow for different kinds of reporting PDFs to be generated. From there he moves into the Ruby world, showing examples of duck typing and modules to avoid duplication (mixins).

0 comments voice your opinion now!
ruby mixin ducktype interface abstract class tutorial


blog comments powered by Disqus

Similar Posts

PHPBuilder.com: Fundamentals of PHP Superglobals

ThinkPHP Blog: Accessing NTLM secured resources with PHP

RubySource.com: Confessions of a Converted PHP Developer: Animal Abuse

HowTo Forge: Installing Lighttpd With PHP5 And MySQL Support On Mandriva 2008.0

Chris Shiflett\'s Blog: ZF Tutorial Update


Community Events





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


laravel library unittest install opinion bugfix interview zendserver voicesoftheelephpant deployment language introduction framework symfony package release community podcast api series

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