News Feed
Sections




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

DZone.com:
The Duck is a Lie
June 27, 2012 @ 09:55:22

In this recent post to DZone.com Giorgio Sironi looks at duck typing and compares it in a few different languages (PHP, Ruby and Java). "Duck typing" is where the methods/functions define the structure or common interface rather than being functional.

What follows is my experience with Java, PHP and Ruby. I mainly use PHP as a dynamic language that supports duck typing but also the definition of Java-like interfaces, but does not force any of the two approaches as you can define interfaces whose method arguments accept any variable or not using interfaces at all. Is duck typing that a revolution?

He shares some of the common misconceptions he's seen including the idea that duck typing can help completely different objects work together and that, sometimes, despite naming conventions, functionality was intended to be different. He shows how even interfaces in PHP can be implemented loosely and the "acts as" and "single callback" architecture ideas.

0 comments voice your opinion now!
duck typing interface misconception actsas callback


blog comments powered by Disqus

Similar Posts

Johannes Schluter's Blog: Jason, let me help you!

Joshua Thompson's Blog: Return to Prototype Based Programming in PHP

OpenSky Blog: Inheritance in PHP, or why you want to use an Interface or an Abstract class...

Matthew Weier O'Phinney's Blog: Why PHP Namespaces Matter

Brian Moon's Blog: Initializing & typing variables with settype()


Community Events





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


framework release threedevsandamaybe laravel version list podcast series voicesoftheelephpant symfony language introduction opinion unittest api community conference interview composer configure

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