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:
Confessions of a Converted PHP Developer Animal Abuse
June 27, 2011 @ 13:40:02

In another entry in his "Confessions of a Converted PHP Developer" series Mal Curtis about a typical class development path PHP developers take and how it can be a limiting, linear progression from one step to another.

In converting to Ruby I realized how strict PHP is in its class hierarchy. This surprised me as I'd always viewed PHP as a very loose language, mainly due to its loose typing and lack of formal code structure guidelines. [...] I find most PHP developers learn starting by using inline PHP as a low learning curve entry point into dynamic web languages and then move on to fuller, more complex, applications.

He includes a few code samples comparing how Ruby, while still allowing the same kind of structure, also lets you redefine classes on the fly. His example shows redefining a method in a Ruby class using a method commonly called "monkey patching". It's good that he points out a downfall of the approach too:

I must note that Monkey Patching is often a quick fix solution that can create headaches for future developers (or for yourself, if your memory is like mine) for several reasons. [...] Use at your own risk!

There's several different articles all over the web talking about the "monkey patching" approach and if it's possible/useful in PHP.

0 comments voice your opinion now!
monkeypatching ruby compare class objectoriented rubysource


blog comments powered by Disqus

Similar Posts

AlternateInterior.com: Multi-Threading Strategies in PHP

DevShed: Intercepting Customized Exceptions in PHP 5

Gaetano Giunta's Blog: A completely fair and balanced comparison of php json libraries

DevShed: PHP 5 Helpers: Calling Methods Out of Object Scope

Knut Urdalen's Blog: Yii Framework 1.0 released!


Community Events





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


voicesoftheelephpant package symfony introduction interview release tool update security composer community mvc laravel library version language framework opinion series podcast

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