News Feed
Jobs Feed
Sections



Recent Jobs

News Archive
feed this:

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



ActsAsFlinn Blog:
PHP and ActiveRecord (continued)
August 13, 2007 @ 15:35:00

In a response to a response (from Arnold Daniels) on his article on the ActiveRecord pattern in PHP, Flinn Mueller has come back once again with more comments, both in response and to share some more opinion on the matter.

Today I saw a big traffic increase from my PHP and ActiveRecord post. It looks like PHPDeveloper posted a link to the article and response, so I've written a response to the Arnold's wor(l)ds response post. Arnold's post is insightful, references runkit and has a good implementation of a Sortable tasklist example in PHP.

Flinn breaks it out into a few different topics - things like:

  • Ruby objects are (native) Ruby objects
  • a brief look at "lineage" for both PHP and Ruby
  • The usefulness of Ruby mix-ins
  • Issues with static inheritance in PHP
  • and some of his suggestions on what PHP6 really needs

1 comment voice your opinion now!
activerecord ruby object lineage mixin php6 activerecord ruby object lineage mixin php6


Ivo Jansch's Blog:
Mixins in PHP
August 25, 2006 @ 08:02:33

In his latest post today, Ivo Jansch talks about a concpt from Ruby that he likes and wanted to try to implment in PHP - mixins.

Mixins are a way of 'mixing in' functionality of other classes. A kind of 'multiple inheritance' like approach, only without actual inheritance. It is similar to interfaces, but interfaces only tell you that an object must implement certain methods, whereas mixins also provide an implementation.

To help clear it up a bit he links to two articles on the topic. He gives some examples, though, of how it all works by creating a mixin class (Alertable) and the wy to apply it (in the Hello class). The key between the two is the Object class he's created. It allows the two other classes to work with each other without the need for cumbersome includes or passing around objects. All methods are magically available to the Hello object.

Of course, it's not a perfect implementation because PHP just can't do some things, but he includes a few of these things to watch out for in using this method.

0 comments voice your opinion now!
mixin ruby php5 class alert multiple inheritance mixin ruby php5 class alert multiple inheritance



Community Events





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


release test framework unittest community database application conference series introduction custom api component podcast language development opinion symfony2 interview phpunit

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